Exemple #1
0
// ***************************************************************************
CMaterialBase::CMaterialBase()
{
    DefaultAmbient.setDefaultValue(CRGBA(64,64,64));
    DefaultDiffuse.setDefaultValue(CRGBA(128,128,128));
    DefaultSpecular.setDefaultValue(CRGBA(0,0,0));
    DefaultShininess.setDefaultValue(10);
    DefaultEmissive.setDefaultValue(CRGBA(128,128,128));
    DefaultOpacity.setDefaultValue(1);
    DefaultTexture.setDefaultValue(0x7FFFFFFF);
    for (uint k = 0; k < IDRV_MAT_MAXTEXTURES; ++k)
    {
        DefaultTexAnimTracks[k].setDefaultValue();
    }
}
//*********************************************************************************************************
CDisplayerVisualActivitySequence::CDisplayerVisualActivitySequence()
{
	_Touched = true;
	_Active = false;
	_AddedToWorldMap = false;
	_DecalColor = CRGBA(0, 0, 0, 0);
}
void		CAsteroid::Draw(CRenderD3D* render)
{
	if (m_State == AS_NONE)
		return;

	CRGBA	col = CRGBA(1.0f, 1.0f, 1.0f, 1.0f);
	if (m_State == AS_EXPLODING)
	{
		col = CRGBA(m_Time/ASTEROIDEXPTIME, m_Time/ASTEROIDEXPTIME, m_Time/ASTEROIDEXPTIME, 1.0f);
	}

	for (int lNr=0; lNr<ASTEROIDNUMLINES; lNr++)
	{
		render->DrawLine(m_Pos+m_Lines[lNr][0].Rotate(m_Rot), m_Pos+m_Lines[lNr][1].Rotate(m_Rot), col, col);
	}
}
Exemple #4
0
//*******************************************************************************
void CWaterEnvMap::renderTestMesh(IDriver &driver)
{
	doInit();
	CMaterial testMat;
	testMat.setLighting(false);
	testMat.texEnvOpRGB(0, CMaterial::Modulate);
	testMat.texEnvArg0RGB(0, CMaterial::Texture, CMaterial::SrcColor);
	testMat.texEnvArg0RGB(1, CMaterial::Diffuse, CMaterial::SrcColor);
	testMat.texEnvOpAlpha(0, CMaterial::Replace);
	testMat.texEnvArg0Alpha(0, CMaterial::Constant, CMaterial::SrcAlpha);
	testMat.texConstantColor(0, CRGBA(255, 255, 255, 255));
	testMat.setDoubleSided(true);
	testMat.setZWrite(false);
	testMat.setZFunc(CMaterial::always);
	// tmp : test cubemap
	driver.activeVertexProgram(&testMeshVP);
	driver.activeVertexBuffer(_TestVB);
	driver.activeIndexBuffer(_TestIB);
	driver.setConstantMatrix(0, IDriver::ModelViewProjection, IDriver::Identity); // tmp
	_MaterialPassThruZTest.setTexture(0, _EnvCubic);
	driver.setConstantMatrix(0, IDriver::ModelViewProjection, IDriver::Identity);
	driver.setConstant(4, 2.f, 1.f, 0.f, 0.f);
	//driver.renderTriangles(testMat, 0, TEST_VB_NUM_TRIS);
	driver.renderTriangles(_MaterialPassThruZTest, 0, TEST_VB_NUM_TRIS);
	driver.activeVertexProgram(NULL);
}
CRGBA HSVtoRGB( float h, float s, float v )
{
  int i;
  float f;
  int r, g, b, p, q, t, m;

  if( s == 0 ) { // achromatic (grey)
    r = g = b = (int)(255*v);
    return CRGBA(r,g,b,255);
  }

  h /= 60;      // sector 0 to 5
  i = (int)( h );
  f = h - i;      // frational part of h
  m = (int)(255*v);
  p = (int)(m * ( 1 - s ));
  q = (int)(m * ( 1 - s * f ));
  t = (int)(m * ( 1 - s * ( 1 - f ) ));

  switch( i ) {
    case 0: return CRGBA(m,t,p,255);
    case 1: return CRGBA(q,m,p,255);
    case 2: return CRGBA(p,m,t,255);
    case 3: return CRGBA(p,q,m,255);
    case 4: return CRGBA(t,p,m,255);
    default: break;    // case 5:
  }
  return CRGBA(m,p,q,255);
}
Exemple #6
0
CRGBA CConfiguration::getValue(const CConfigFile::CVar &var, const CRGBA &defaultValue)
{
	if (var.size() >= 3)
	{
		if (var.size() > 4) nlwarning("RGBA value in config value '%s' is too long, ignoring unused values");
		return CRGBA((uint8)var.asInt(0), (uint8)var.asInt(1), (uint8)var.asInt(2), var.size() >= 4 ? (uint8)var.asInt(3) : 255);
	}
	nlwarning("Invalid RGBA value in config value '%s', reverting to default { %i, %i, %i, %i }", var.Name.c_str(), (sint)defaultValue.R, (sint)defaultValue.G, (sint)defaultValue.B, (sint)defaultValue.A);	
	return defaultValue;
}
Exemple #7
0
void
CGnuPlotMark::
init(CGnuPlotPlot *plot)
{
  const CGnuPlotLineStyle &lineStyle = plot->lineStyle();

  size_  = plot->pointSize();
  type_  = plot->pointType();
  color_ = lineStyle.calcColor(plot->group(), CRGBA(0,0,0));
  width_ = lineStyle.calcWidth();
}
Exemple #8
0
	// ------------------------------------------------------------------------------------------------
	void CCtrlColPick::draw()
	{
		CViewRenderer &rVR = *CViewRenderer::getInstance();

		CRGBA col = CRGBA(255,255,255,(uint8)CWidgetManager::getInstance()->getGlobalColor().A);

		rVR.drawRotFlipBitmap (_RenderLayer, _XReal, _YReal,
								_WReal, _HReal,
								0, false,
								_Texture,
								col );
	}
void
CQGnuPlotColorBox::
draw(CGnuPlotRenderer *renderer)
{
  if (! isEnabled())
    return;

  CGnuPlotColorBox::draw(renderer);

  if (isSelected())
    renderer->drawRect(bbox(), CRGBA(1,0,0), 2);
}
// *********************************************************************************************************
CRGBA CDisplayerVisual::getDisplayModeColorInScene() const
{
	//H_AUTO(R2_CDisplayerVisual_getDisplayModeColorInScene)
	switch(getActualDisplayMode())
	{
		case DisplayModeVisible: return CV_UnselectedInstanceColor.get();
		case DisplayModeFrozen: return CV_FrozenInstanceColor.get();
		case DisplayModeLocked: return CV_LockedInstanceColor.get();
		case DisplayModeArray: return CV_ArrayInstanceColor.get();
		default: return CRGBA(0, 0, 0 ,0);
	}
}
// *********************************************************************************************************
CRGBA CDisplayerVisual::getDisplayModeColorInMap() const
{
	//H_AUTO(R2_CDisplayerVisual_getDisplayModeColorInMap)
	switch(getActualDisplayMode())
	{
		case DisplayModeVisible: return CRGBA::White;
		case DisplayModeFrozen: return CV_MapEntityFrozenColor.get();
		case DisplayModeLocked: return CV_MapEntityLockedColor.get();
		case DisplayModeArray: return CV_ArrayInstanceColor.get();
		default: return CRGBA(0, 0, 0 ,0);
	}
}
Exemple #12
0
void
CSVGBuffer::
reset()
{
  CSVGRenderer *renderer = getRenderer();

  renderer->setDataRange(0, 0, 1, 1);

  renderer->setViewMatrix(CMatrix2D(CMATRIX_TYPE_IDENTITY));

  //------

  CImagePtr image = renderer->getImage();

  if (image.isValid())
    image->setRGBAData(CRGBA(0,0,0,0));

  //------

  renderer->setStrokeColor(CRGBA(0,0,0,1));
  renderer->setFillColor  (CRGBA(0,0,0,1));
}
Exemple #13
0
// ***************************************************************************
void			CMaterial::initUnlit()
{
	setShader(Normal);
	setLighting(false);
	setColor(CRGBA(255,255,255,255));
	for(uint32 i=0;i<IDRV_MAT_MAXTEXTURES;i++)
		setTexture((uint8)i ,NULL);
	setZBias(0);
	setZFunc(lessequal);
	setZWrite(true);
	setBlend(false);
	setAlphaTestThreshold(0.5f);
}
Exemple #14
0
//*******************************************************************************
void CWaterEnvMap::update(TGlobalAnimationTime time, IDriver &driver)
{
	if (_LastRenderTime == time) return;
	_LastRenderTime = time;
	// First five updates are used to render the cubemap faces (bottom face is not rendered)
	// Sixth update project the cubemap into a 2D texture
	uint numTexToRender;
	if (_UpdateTime > 0)
	{
		uint64 currRenderTick = (uint64) (time / (_UpdateTime / (NUM_FACES_TO_RENDER + 1)));
		numTexToRender = (uint) (currRenderTick - _LastRenderTick);
		_LastRenderTick = currRenderTick;
	}
	else
	{
		numTexToRender = NUM_FACES_TO_RENDER + 1;
	}
	if (!numTexToRender) return;
	if (_NumRenderedFaces == 0)
	{
		_StartRenderTime = time;
	}
	uint lastCubeFacesToRender = std::min((uint) NUM_FACES_TO_RENDER, _NumRenderedFaces + numTexToRender); // we don't render negative Z (only top hemisphere is used)
	for(uint k = _NumRenderedFaces; k < lastCubeFacesToRender; ++k)
	{
		driver.setRenderTarget(_EnvCubic, 0, 0, _EnvCubicSize, _EnvCubicSize, 0, (uint32) k);
		render((CTextureCube::TFace) k, _StartRenderTime);
	}
	_NumRenderedFaces = lastCubeFacesToRender;
	if (_NumRenderedFaces == NUM_FACES_TO_RENDER && (_NumRenderedFaces + numTexToRender) > NUM_FACES_TO_RENDER)
	{
		// render to 2D map
		driver.setRenderTarget(_Env2D, 0, 0, _Env2DSize, _Env2DSize);
		doInit();
		//
		driver.activeVertexProgram(NULL);
		driver.activeVertexBuffer(_FlattenVB);
		driver.activeIndexBuffer(_FlattenIB);
		driver.setFrustum(-1.f, 1.f, -1.f, 1.f, 0.f, 1.f, false);
		driver.setupViewMatrix(CMatrix::Identity);
		CMatrix mat;
		//mat.scale(0.8f);
		driver.setupModelMatrix(mat);
		_MaterialPassThru.setTexture(0, _EnvCubic);
		_MaterialPassThru.texConstantColor(0, CRGBA(255, 255, 255, _Alpha));
		driver.renderTriangles(_MaterialPassThru, 0, FVB_NUM_TRIS);
		_NumRenderedFaces = 0; // start to render again
	}
	driver.setRenderTarget(NULL);
}
Exemple #15
0
	// ***************************************************************************
	bool CDBViewDigit::parse (xmlNodePtr cur, CInterfaceGroup * parentGroup)
	{
		if(!CViewBase::parse(cur, parentGroup))
			return false;

		CViewRenderer &rVR = *CViewRenderer::getInstance();

		// link to the db
		CXMLAutoPtr ptr;
		ptr = xmlGetProp (cur, (xmlChar*)"value");
		if ( ptr )
			_Number.link ( ptr );
		else
		{
			nlinfo ("no value in %s", _Id.c_str());
			return false;
		}

		// read options
		ptr = xmlGetProp (cur, (xmlChar*)"numdigit");
		if(ptr)	fromString((const char*)ptr, _NumDigit);
		clamp(_NumDigit, 1, 10);

		ptr = xmlGetProp (cur, (xmlChar*)"wspace");
		if(ptr)	fromString((const char*)ptr, _WSpace);

		ptr= (char*) xmlGetProp( cur, (xmlChar*)"color" );
		_Color = CRGBA(255,255,255,255);
		if (ptr)
			_Color = convertColor (ptr);

		// compute window size. Remove one space.
		sint32	wDigit= rVR.getFigurTextureW();
		sint32	hDigit= rVR.getFigurTextureH();
		setW((wDigit+_WSpace)*_NumDigit - _WSpace);
		setH(hDigit);

		// some init
		// For _NumDigit=2; set the divBase to 100, etc...
		_DivBase= 1;
		for(uint i= 0;i<(uint)_NumDigit;i++)
		{
			_DivBase*= 10;
		}

		// init cache.
		_Cache= -1;

		return true;
	}
Exemple #16
0
CRGBA
CRayShape::
getColor(const CPoint3D &p) const
{
  if (texture_.isValid()) {
    if (texture_->isPointTexture())
      return textureValue(p);

    CVector2D uv = pointToSurfaceVector(p);

    return textureValue(uv);
  }

  return CRGBA(1,1,1);
}
Exemple #17
0
//-----------------------------------------------
// getRGBA :
// Get all value for a RGBA in the script.
//-----------------------------------------------
CRGBA getRGBA()
{
	char delimiter[] = "[] \t";
	uint8 rgba[4]   = {255,255,255,255};
	char *ptr;

	for(uint rgbaIndex = 0; rgbaIndex<4; ++rgbaIndex)
	{
		ptr = strtok(NULL, delimiter);
		if(ptr != NULL)
			rgba[rgbaIndex] = atoi(ptr);
		else
			break;
	}
	return CRGBA(rgba[0], rgba[1], rgba[2], rgba[3]);
}// getRGBA //
Exemple #18
0
CRGBA
CSVGStroke::
getAlphaColor() const
{
  CRGBA rgba;

  if (color_.getValid()) {
    rgba = color_.getValue();

    if (getOpacityValid())
      rgba.setAlpha(getOpacity());
  }
  else
    rgba = CRGBA(0,0,0,0);

  return rgba;
}
Exemple #19
0
//*******************************************************************************
void CWaterEnvMap::doInit()
{
	if (!_FlattenVBInitialized)
	{
		initFlattenVB();
		initTestVB();
		_FlattenVBInitialized = true;
		_MaterialPassThru.setLighting(false);
		_MaterialPassThru.texEnvOpRGB(0, CMaterial::Replace);
		_MaterialPassThru.texEnvArg0RGB(0, CMaterial::Texture, CMaterial::SrcColor);
		_MaterialPassThru.texEnvOpAlpha(0, CMaterial::Replace);
		_MaterialPassThru.texEnvArg0Alpha(0, CMaterial::Constant, CMaterial::SrcAlpha);
		_MaterialPassThru.texConstantColor(0, CRGBA(255, 255, 255, 255));
		_MaterialPassThru.setDoubleSided(true);
		_MaterialPassThruZTest = _MaterialPassThru;
		_MaterialPassThru.setZWrite(false);
		_MaterialPassThru.setZFunc(CMaterial::always);
	}
}
Exemple #20
0
void
CSVGStroke::
setColor(const string &color_def)
{
  if (color_def == "none") {
    setColor(CRGBA(0,0,0,0));

    setOpacity(0.0);
  }
  else {
    CRGBA rgba;

    if (svg_.decodeColorString(color_def, rgba)) {
      setColor(rgba);

      if (! getOpacityValid())
        setOpacity(1.0);
    }
  }
}
Exemple #21
0
// ***************************************************************************
void CScene::renderOcclusionTestMeshs()
{
	nlassert(RenderTrav.getDriver());
	RenderTrav.getDriver()->setupViewport(RenderTrav.getViewport());
	RenderTrav.getDriver()->activeVertexProgram(NULL);
	RenderTrav.getDriver()->activePixelProgram(NULL);
	RenderTrav.getDriver()->activeGeometryProgram(NULL);
	IDriver::TPolygonMode oldPolygonMode = RenderTrav.getDriver()->getPolygonMode();
	CMaterial m;
	m.initUnlit();
	m.setColor(CRGBA(255, 255, 255, 127));
	m.setBlend(true);
	m.setDstBlend(CMaterial::invsrcalpha);
	m.setSrcBlend(CMaterial::srcalpha);
	m.setZWrite(false);
	RenderTrav.getDriver()->setupMaterial(m);
	getDriver()->setPolygonMode(IDriver::Filled);
	renderOcclusionTestMeshsWithCurrMaterial();
	m.setColor(CRGBA::Black);
	RenderTrav.getDriver()->setupMaterial(m);
	getDriver()->setPolygonMode(IDriver::Line);
	renderOcclusionTestMeshsWithCurrMaterial();
	getDriver()->setPolygonMode(oldPolygonMode);
}
Exemple #22
0
	void RenderModelSkinned(CModelSkinned* pModelSkinned)
	{
		glPushMatrix();

		glTranslatef(Vec3Expand(pModelSkinned->GetPosition()));
		glRotatef(pModelSkinned->GetRotation().q[0], 0, 1, 0);
//		glRotatef(-90, 1, 0, 0);
//		glScalef(Vec3Expand(pModelSkinned->GetModel()->GetScale()));

/*		glDisable(GL_TEXTURE_2D);
		glBegin(GL_LINES);
			glVertex3f(-pModelSkinned->GetDims().x/2,0,-pModelSkinned->GetDims().z/2);
			glVertex3f(-pModelSkinned->GetDims().x/2,pModelSkinned->GetDims().y,-pModelSkinned->GetDims().z/2);
			glVertex3f(-pModelSkinned->GetDims().x/2,0,-pModelSkinned->GetDims().z/2);
			glVertex3f(-pModelSkinned->GetDims().x/2,0,pModelSkinned->GetDims().z/2);
			glVertex3f(-pModelSkinned->GetDims().x/2,0,-pModelSkinned->GetDims().z/2);
			glVertex3f(pModelSkinned->GetDims().x/2,0,-pModelSkinned->GetDims().z/2);

			glVertex3f(+pModelSkinned->GetDims().x/2,0,+pModelSkinned->GetDims().z/2);
			glVertex3f(+pModelSkinned->GetDims().x/2,pModelSkinned->GetDims().y,+pModelSkinned->GetDims().z/2);
			glVertex3f(+pModelSkinned->GetDims().x/2,0,+pModelSkinned->GetDims().z/2);
			glVertex3f(+pModelSkinned->GetDims().x/2,0,-pModelSkinned->GetDims().z/2);
			glVertex3f(+pModelSkinned->GetDims().x/2,0,+pModelSkinned->GetDims().z/2);
			glVertex3f(-pModelSkinned->GetDims().x/2,0,+pModelSkinned->GetDims().z/2);

			glVertex3f(+pModelSkinned->GetDims().x/2,pModelSkinned->GetDims().y,-pModelSkinned->GetDims().z/2);
			glVertex3f(+pModelSkinned->GetDims().x/2,0,-pModelSkinned->GetDims().z/2);
			glVertex3f(-pModelSkinned->GetDims().x/2,pModelSkinned->GetDims().y,-pModelSkinned->GetDims().z/2);
			glVertex3f(-pModelSkinned->GetDims().x/2,pModelSkinned->GetDims().y,pModelSkinned->GetDims().z/2);
			glVertex3f(-pModelSkinned->GetDims().x/2,pModelSkinned->GetDims().y,-pModelSkinned->GetDims().z/2);
			glVertex3f(pModelSkinned->GetDims().x/2,pModelSkinned->GetDims().y,-pModelSkinned->GetDims().z/2);

			glVertex3f(-pModelSkinned->GetDims().x/2,pModelSkinned->GetDims().y,+pModelSkinned->GetDims().z/2);
			glVertex3f(-pModelSkinned->GetDims().x/2,0,+pModelSkinned->GetDims().z/2);
			glVertex3f(+pModelSkinned->GetDims().x/2,pModelSkinned->GetDims().y,+pModelSkinned->GetDims().z/2);
			glVertex3f(+pModelSkinned->GetDims().x/2,pModelSkinned->GetDims().y,-pModelSkinned->GetDims().z/2);
			glVertex3f(+pModelSkinned->GetDims().x/2,pModelSkinned->GetDims().y,+pModelSkinned->GetDims().z/2);
			glVertex3f(-pModelSkinned->GetDims().x/2,pModelSkinned->GetDims().y,+pModelSkinned->GetDims().z/2);

		glEnd();
		glEnable(GL_TEXTURE_2D);
*/
		GL::SetColor(CRGBA(255,255,255,255));
		glEnableClientState(GL_VERTEX_ARRAY);
		glEnableClientState(GL_NORMAL_ARRAY);

		CalModel* pCalModel = (CalModel*)pModelSkinned->GetCalModel();
//		pCalModel->update(GetTime()->GetTimeDelta());

		// get the renderer of the model
		CalRenderer *pCalRenderer = pCalModel->getRenderer();

		// begin the rendering loop
		if(!pCalRenderer->beginRendering())
		{
			// error handling ...
		}

		int	meshCount = pCalRenderer->getMeshCount();
		for(int meshId = 0; meshId < meshCount; meshId++)
		{
			ModelSkinnedMesh msm;
			msm.pModelSkinned = pModelSkinned;
			msm.nMeshId = meshId;

			RenderShader(pModelSkinned->GetModel()->GetShader(meshId), pModelSkinned->GetTint(), CRender::RenderFacesModelSkinned, &msm);
		}

		// end the rendering of the model
		pCalRenderer->endRendering();

		glDisableClientState(GL_NORMAL_ARRAY);
		glDisableClientState(GL_VERTEX_ARRAY);

		glPopMatrix();
	}
void
CGnuPlotStyleRadar::
draw2D(CGnuPlotPlot *plot, CGnuPlotRenderer *renderer)
{
  CGnuPlotRadarStyleValue *value =
    CGnuPlotStyleValueMgrInst->getValue<CGnuPlotRadarStyleValue>(plot);

  if (! value) {
    value = plot->app()->device()->createRadarStyleValue(plot);

    CGnuPlotStyleValueMgrInst->setValue<CGnuPlotRadarStyleValue>(plot, value);
  }

  //---

  const CBBox2D &bbox = plot->bbox2D();

  CPoint2D pc = bbox.getCenter();
  double   r  = bbox.getWidth()/2;

  int np = -1;

  for (const auto &point : plot->getPoints2D()) {
    np = std::min(np < 0 ? INT_MAX : np, point.getNumValues());
  }

  if (np < 3)
    return;

  //double pw = renderer->pixelWidthToWindowWidth  (1);
  //double ph = renderer->pixelHeightToWindowHeight(1);

  CGnuPlotGroup *group = plot->group();

  const CGnuPlotKeyData  &keyData = plot->keyData();
  const CGnuPlotAxisData &xaxis   = group->xaxis(1);

  const CGnuPlotKey::Columns &columns = keyData.columns();

  double da = 360/np;

  std::vector<CPoint2D> points = radarPoints(value->angleStart(), pc, r, np);

  double v = getRange(plot);

  //---

  // draw border
  renderer->drawPolygon(points, value->borderColor(), value->borderWidth(), value->borderDash());

  //---

  // draw column labels (how determine indices)
  {
    double a = value->angleStart();

    for (int i = 1; i <= np && i < int(columns.size()); ++i) {
      CPoint2D p = radarPoint(pc, r, a);

      CHAlignType halign = CHALIGN_TYPE_CENTER;
      CVAlignType valign = CVALIGN_TYPE_CENTER;

      double dx = 0;
      double dy = 0;

      if      (p.x < pc.x - v/2) {
        halign = CHALIGN_TYPE_RIGHT;
        dx     = -8;
      }
      else if (p.x > pc.x + v/2) {
        halign = CHALIGN_TYPE_LEFT;
        dx     = 8;
      }

      if      (p.y < pc.y - v/2) {
        valign = CVALIGN_TYPE_TOP;
        dy     = 8;
      }
      else if (p.y > pc.y + v/2) {
        valign = CVALIGN_TYPE_BOTTOM;
        dy     = -8;
      }

      CRGBA tc = CRGBA(0,0,0);

      renderer->drawHAlignedText(p, HAlignPos(halign, dx), VAlignPos(valign, dy), columns[i], tc),

      a -= da;
    }
  }

  //---

  // draw axis if needed
  if (xaxis.isDisplayed()) {
    CRGBA ac = value->axisColor();

    ac.setAlpha(value->axisAlpha());

    double dr = 0.1;
    double ra = 0.1;

    while (ra < v) {
      std::vector<CPoint2D> points1 = radarPoints(value->angleStart(), pc, ra, np);

      renderer->drawPolygon(points1, ac, value->axisWidth(), value->axisDash());

      ra += dr;
    }

    for (const auto &p : points)
      renderer->drawLine(p, pc, ac, value->axisWidth(), value->axisDash());
  }

  //---

  bool cache = false;

  if (! renderer->isPseudo() && plot->isCacheActive()) {
    plot->updatePolygonCacheSize(plot->numPoints2D());

    cache = true;
  }

  int pi = 0;

  for (const auto &point : plot->getPoints2D()) {
    std::vector<CPoint2D> points1;

    double a = value->angleStart();

    for (int i = 0; i < np; ++i) {
      double v1;

      if (! point.getValue(i + 1, v1))
        continue;

      CPoint2D p = radarPoint(pc, v1, a);

      points1.push_back(p);

      a -= da;
    }

    CRGBA lc, fc;

    getPointsColor(value, pi + 1, lc, fc);

    if (cache) {
    //std::string label = (pi < int(columns.size()) ? columns[pi] : "");
      std::string label = xaxis.iticLabel(pi);

      auto polygon = plot->polygonObjects()[pi];

      polygon->setPoints(points1);
      polygon->setTipText(label);

      if (! polygon->testAndSetUsed()) {
        CGnuPlotFillP   fill  (polygon->fill  ()->dup());
        CGnuPlotStrokeP stroke(polygon->stroke()->dup());

        fill->setColor(fc);
        fill->setType (CGnuPlotTypes::FillType::SOLID);

        stroke->setColor   (lc);
        stroke->setWidth   (value->strokeWidth());
        stroke->setLineDash(value->strokeDash());

        polygon->setFill  (fill  );
        polygon->setStroke(stroke);
      }
    }
    else {
      renderer->fillPolygon(points1, fc);

      renderer->drawPolygon(points1, lc, value->strokeWidth(), value->strokeDash());
    }

    ++pi;
  }

  if (cache) {
    for (const auto &polygon : plot->polygonObjects())
      polygon->draw(renderer);
  }
}
Exemple #24
0
	void CObjectViewer::cfcbBackgroundColor(NLMISC::CConfigFile::CVar &var)
	{
		// read variable from config file
		_BackgroundColor = CRGBA(var.asInt(0), var.asInt(1), var.asInt(2));
	}
Exemple #25
0
bool
CImageSIX::
read(CFile *file, CImagePtr &image)
{
  file->rewind();

  CFileParse parse(file);

  if (! parse.isChar('\033'))
    return false;

  parse.skipChar();

  if (! parse.isChar('P'))
    return false;

  parse.skipChar();

  // semi-colon separated values ending in 'q'

  std::vector<int> parameters;

  while (! parse.eof()) {
    if (parse.isChar('q'))
      break;

    int p = parse.readChar();

    parameters.push_back(p);

    if (! parse.isChar(';'))
      break;

    parse.skipChar();
  }

  if (! parse.isChar('q'))
    return false;

  parse.skipChar();

  int w = 0, h = 0;

  std::vector<CRGBA> colors;

  while (! parse.eof()) {
    if      (parse.isChar('\"')) {
      parse.skipChar();

      std::vector<int> parameters;

      readParameters(parse, parameters);

      if (parameters.size() == 4) {
        w = parameters[2];
        h = parameters[3];
      }
    }
    else if (parse.isChar('#')) {
      parse.skipChar();

      std::vector<int> parameters;

      readParameters(parse, parameters);

      if (parameters.size() == 5) {
        int r = parameters[2];
        int g = parameters[3];
        int b = parameters[4];

        colors.push_back(CRGBA(r/255.0, g/255.0, b/255.0));
      }
    }
    else {
      break;
    }
  }

  //------

  image->setType(CFILE_TYPE_IMAGE_SIX);

  image->setDataSize(w, h);

  for (const auto &color : colors)
    image->addColor(color);

  uint *data = new uint [w*h];

  //---

  int c = 0;
  int x = 0;
  int y = 0;

  while (! parse.eof()) {
    if (parse.isChar('\033')) {
      parse.skipChar();

      if (parse.isChar('\\'))
        break;

      //data.push_back('\033');

      return false;
    }
    // repeat data
    else if (parse.isChar('!')) {
      parse.skipChar();

      int parameter;

      if (! readParameter(parse, parameter))
        break;

      int d;

      if (! readSixData(parse, d))
        break;

      for (int i = 0; i < parameter; ++i) {
        for (int i = 0; i < 6; ++i) {
          bool b = d & (1<<i);

          if (b) data[x + (y + i)*w] = c;
        }

        ++x;
      }
    }
    // choose palette color
    else if (parse.isChar('#')) {
      parse.skipChar();

      int parameter;

      if (! readParameter(parse, parameter))
        break;

      c = parameter;
    }
    // carriage return
    else if (parse.isChar('$')) {
      parse.skipChar();

      x = 0;
    }
    // next line
    else if (parse.isChar('-')) {
      parse.skipChar();

      x = 0;

      y += 6;
    }
    // add data
    else {
      int d;

      if (! readSixData(parse, d))
        break;

      for (int i = 0; i < 6; ++i) {
        bool b = d & (1<<i);

        if (b) data[x + (y + i)*w] = c;
      }

      ++x;
    }
  }

  //------

  image->setColorIndexData(data);

  delete [] data;

  //------

  return true;
}
Exemple #26
0
	void CObjectViewer::init(nlWindow wnd, uint16 w, uint16 h)
	{
		//H_AUTO2
		nldebug("CObjectViewer::init");

		// load and set remap extensions from config
		//Modules::config().configRemapExtensions();

		// load and set search paths from config
		//Modules::config().configSearchPaths();

		// set background color from config
		Modules::config().setAndCallback("BackgroundColor", CConfigCallback(this, &CObjectViewer::cfcbBackgroundColor));	

		// set graphics driver from config
		Modules::config().setAndCallback("GraphicsDriver",CConfigCallback(this,&CObjectViewer::cfcbGraphicsDriver));

		// create the driver
		nlassert(!_Driver);

		_Driver = UDriver::createDriver(NULL, _Direct3D, NULL);
		nlassert(_Driver);

		// initialize the window with config file values
		_Driver->setDisplay(wnd, NL3D::UDriver::CMode(w, h, 32));

		_Light = ULight::createLight();

		// set mode of the light
		_Light->setMode(ULight::DirectionalLight);

		// set position of the light
		_Light->setPosition(CVector(-20.f, 30.f, 10.f));

		// white light
		_Light->setAmbiant(CRGBA(255, 255, 255));

		// set and enable the light
		_Driver->setLight(0, *_Light);
		_Driver->enableLight(0);

		// Create a scene
		_Scene = _Driver->createScene(true);

		_PlayListManager = _Scene->createPlayListManager();

		_Scene->enableLightingSystem(true);

		// create the camera
		UCamera camera = _Scene->getCam();

		camera.setTransformMode (UTransformable::DirectMatrix);

		setSizeViewport(w, h);

		// camera will look at entities
		updateCamera(0,0,0);

		NLMISC::CVector hotSpot=NLMISC::CVector(0,0,0);

		_MouseListener = _Driver->create3dMouseListener();
		_MouseListener->setMatrix(Modules::objView().getScene()->getCam().getMatrix());
		_MouseListener->setFrustrum(Modules::objView().getScene()->getCam().getFrustum());
		_MouseListener->setHotSpot(hotSpot);
		_MouseListener->setMouseMode(U3dMouseListener::edit3d);
	}
void CLODLightManager::LoadDatFile()
{
	CIniReader iniReader("");
	char* DataFilePath = (char*)iniReader.GetIniPath().c_str();
	char* tempPointer;
	tempPointer = strrchr(DataFilePath, '.');
	*tempPointer = '\0';
	strcat(DataFilePath, ".dat");

	if (FILE* hFile = CFileMgr::OpenFile(DataFilePath, "r"))
	{
		unsigned short	nModel = 0xFFFF, nCurIndexForModel = 0;

		while (const char* pLine = CFileMgr::LoadLine(hFile))
		{
			if (pLine[0] && pLine[0] != '#')
			{
				if (pLine[0] == '%')
				{
					nCurIndexForModel = 0;
					if (strcmp(pLine, "%additional_coronas") != 0)
					{
						if (bIsIVEFLC)
							nModel = CLODLightManager::IV::GetHashKey((char *)(pLine + 1), 0);
						else
							nModel = GetModelInfoUInt16(pLine + 1);
					}
					else
						nModel = 65534;
				}
				else
				{
					float			fOffsetX, fOffsetY, fOffsetZ;
					unsigned int	nRed, nGreen, nBlue, nAlpha;
					float			fCustomSize = 1.0f;
					int				nNoDistance = 0;
					int				nDrawSearchlight = 0;
					int				nCoronaShowMode = 0;
					sscanf(pLine, "%d %d %d %d %f %f %f %f %d %d %d", &nRed, &nGreen, &nBlue, &nAlpha, &fOffsetX, &fOffsetY, &fOffsetZ, &fCustomSize, &nCoronaShowMode, &nNoDistance, &nDrawSearchlight);
					pFileContent->insert(std::make_pair(PackKey(nModel, nCurIndexForModel++), CLamppostInfo(CVector(fOffsetX, fOffsetY, fOffsetZ), CRGBA(static_cast<unsigned char>(nRed), static_cast<unsigned char>(nGreen), static_cast<unsigned char>(nBlue), static_cast<unsigned char>(nAlpha)), fCustomSize, nCoronaShowMode, nNoDistance, nDrawSearchlight, 0.0f)));
				}
			}
		}

		m_bCatchLamppostsNow = true;
		CFileMgr::CloseFile(hFile);
	}
	else
	{
		bRenderLodLights = 0;
		bRenderSearchlightEffects = 0;
	}
}
Exemple #28
0
					str[strIdx] = character.character;
					strIdx++;
				}
			}

			if (strIdx > 0)
			{
				// reset
				str[strIdx] = L'\0';

				strIdx = 0;

				// convert to a wstring manually and trim off any trailing spaces (as they make font-renderer sad)
				fwWString strBits(str);
				strBits.erase(strBits.find_last_not_of(' ') + 1);

				// write!
				CRect frontRect((strStart * 16.0f) + 8.0f, y + 8.0f, GetScreenResolutionX() - 8.0f, y + 8.0f);

				TheFonts->DrawText(strBits, frontRect, frontColor, 16.0f, 1.0f, "Lucida Console");
			}
		}

		int cx, cy;
		ConHost_GetCursorPos(cx, cy);

		CRect cursorRect(cx * stringRect.Width() + 8.0f, cy * 16.0f + 14.0f + 8.0f, cx * stringRect.Width() + stringRect.Width() + 8.0f, cy * 16.0f + 16.0f + 8.0f);

		TheFonts->DrawRectangle(cursorRect, CRGBA(255, 255, 255));
	}, 90);
});
//=======================================
CPSColoredParticle::CPSColoredParticle() : _Color(CRGBA(255, 255, 255)), _ColorScheme(NULL)
{
	NL_PS_FUNC(CPSColoredParticle_CPSColoredParticle)
}
void
CGnuPlotStyleRadar::
drawKey(CGnuPlotPlot *plot, CGnuPlotRenderer *renderer)
{
  CGnuPlotRadarStyleValue *value =
    CGnuPlotStyleValueMgrInst->getValue<CGnuPlotRadarStyleValue>(plot);
  if (! value) return;

  //---

  CGnuPlotGroup *group = plot->group();

  const CGnuPlotKeyP     &key   = group->key();
  const CGnuPlotAxisData &xaxis = group->xaxis(1);

  if (! key->isDisplayed()) return;

  if (key->getFont().isValid())
    renderer->setFont(key->getFont());

  CGnuPlotFill fill(plot);

  //---

  CBBox2D rbbox = (key->isOutside() ? group->getRegionBBox() : renderer->range());

  //---

  CFontPtr font = renderer->getFont();

  double font_size = font->getCharAscent() + font->getCharDescent();

  double pw = renderer->pixelWidthToWindowWidth  (1);
  double ph = renderer->pixelHeightToWindowHeight(1);

  double bx = 8*pw;
  double by = 8*ph;
  double bw = font_size - 2;

  CSize2D size;

  double textWidth = 0.0, textHeight = 0.0;

  std::string header;

  if (key->hasTitle()) {
    header = key->title();

    if (header != "")
      textHeight += font_size*ph;
  }

  int i = 0;

  for (const auto &point : plot->getPoints2D()) {
    assert(! point.isDiscontinuity());

    std::string label = xaxis.iticLabel(i);
    //std::string label = point.label();

    textWidth = std::max(textWidth, font->getStringWidth(label)*pw);

    textHeight += font_size*ph;

    ++i;
  }

  size = CSize2D(textWidth + bw*pw + 3*bx, textHeight + 2*by);

  CHAlignType halign = key->getHAlign();
  CVAlignType valign = key->getVAlign();

  double x1 = 0, y1 = 0;

  if      (halign == CHALIGN_TYPE_LEFT)
    x1 = rbbox.getLeft () + bx;
  else if (halign == CHALIGN_TYPE_RIGHT)
    x1 = rbbox.getRight() - bx - size.getWidth();
  else if (halign == CHALIGN_TYPE_CENTER)
    x1 = rbbox.getXMid() - size.getWidth()/2;

  if      (valign == CVALIGN_TYPE_TOP)
    y1 = rbbox.getTop   () - by - size.getHeight();
  else if (valign == CVALIGN_TYPE_BOTTOM)
    y1 = rbbox.getBottom() + by;
  else if (valign == CVALIGN_TYPE_CENTER)
    y1 = rbbox.getYMid() - size.getHeight()/2;

  double x2 = x1 + size.getWidth ();
  double y2 = y1 + size.getHeight();

  CBBox2D bbox(x1, y1, x2, y2);

  if (key->getFillBox()) {
    renderer->fillRect(bbox, fill.background());
  }

  if (key->getDrawBox()) {
    CRGBA c(0, 0, 0);

    if (key->hasLineType())
      c = CGnuPlotStyleInst->indexColor(value->palette(), key->getLineType());

    renderer->drawRect(bbox, c, 1);
  }

  double y = y2 - by;

  if (header != "") {
    CRGBA tc = CRGBA(0,0,0);

    renderer->drawHAlignedText(CPoint2D((x1 + x2)/2, y), HAlignPos(CHALIGN_TYPE_CENTER, 0),
                               VAlignPos(CVALIGN_TYPE_TOP, 0), header, tc);

    y -= font_size*ph;
  }

  int pi = 0;

  for (const auto &point : plot->getPoints2D()) {
    assert(! point.isDiscontinuity());

    double xx = (key->isReverse() ? x1 + bx : x2 - bw*pw - bx);
    double yy = y - font_size*ph/2;

    CPoint2D p1(xx, yy - bw*ph/2), p2(xx + bw*pw, yy + bw*ph/2);

    CRGBA lc, fc;

    getPointsColor(value, pi + 1, lc, fc);

    CBBox2D bbox(p1, p2);

    renderer->fillRect(bbox, fc);
    renderer->drawRect(bbox, lc, 1);

    std::string label = xaxis.iticLabel(pi);
    //std::string label = point.label();

    //double lw = font->getStringWidth(label);

    CRGBA tc = CRGBA(0,0,0);

    if (key->isReverse())
      renderer->drawHAlignedText(CPoint2D(xx + bw*pw + bx, y), HAlignPos(CHALIGN_TYPE_LEFT, 0),
                                 VAlignPos(CVALIGN_TYPE_TOP, 0), label, tc);
    else
      renderer->drawHAlignedText(CPoint2D(xx - bx, y), HAlignPos(CHALIGN_TYPE_RIGHT, 0),
                                 VAlignPos(CVALIGN_TYPE_TOP, 0), label, tc);

    y -= font_size*ph;

    ++pi;
  }
}