Пример #1
0
		Circle::Circle(const float32 x, const float32 y, const float32 radius, const uint32 vertices) : Renderable((vertices * 2) + 2, 2),
																									    vertices(vertices),
																										radius(radius),
																										borderThickness(0.0f),
																										borderFill(color::Green),
																										fill(color::Red) {
			transform.position.x = x;
			transform.position.y = y;
			transform.origin.x = radius;
			transform.origin.y = radius;

			localBounds.w = radius * 2.0f;
			localBounds.h = radius * 2.0f;
			
			RenderElementData& shapeRenderData = renderData.renderElements[0];
			shapeRenderData.first = 0;
			shapeRenderData.last = vertices + 1;	// +1 caused by center vertex.
			shapeRenderData.vertexElements = 7;		
			shapeRenderData.offset = 2;
			shapeRenderData.renderMode = RenderMode::TriangleFan;

			RenderElementData& borderRenderData = renderData.renderElements[1];
			borderRenderData.first = vertices + 2;		// End of shape vertices + shape center + border center.
			borderRenderData.last = vertices * 2 + 1;	// Shape + border center offset.
			borderRenderData.vertexElements = 7;
			borderRenderData.offset = 2;
			borderRenderData.renderMode = RenderMode::TriangleFan;

			recomputeBounds(*this);
			recomputeVertices(*this);
			updateRenderData(*this);
		}
Пример #2
0
  void
  SVisualizer::initialise(size_t nID)
  {
    ID = nID;

    //Add all of the objects to be rendered
    _particleData.reset(new coil::DataSet("Particles", Sim->N()));
    _window->addRenderObj(_particleData);

    for (shared_ptr<Local>& local : Sim->locals)
      {
	CoilRenderObj* obj = dynamic_cast<CoilRenderObj*>(&(*local));
	if (obj != NULL) {
	  _window->addRenderObj(obj->getCoilRenderObj());
	  _window->_updateDataSignal.connect<CoilRenderObj, &CoilRenderObj::updateRenderData>(obj);
	}
      }
    
    for (shared_ptr<Global>& global : Sim->globals)
      {
	CoilRenderObj* obj = dynamic_cast<CoilRenderObj*>(&(*global));
	if (obj != NULL) {
	  _window->addRenderObj(obj->getCoilRenderObj());
	  _window->_updateDataSignal.connect<CoilRenderObj, &CoilRenderObj::updateRenderData>(obj);
	}
      }

    //Initialise coil
    _coil.getInstance().addWindow(_window);

    //Now initialise data
    initDataSet();

    for (shared_ptr<Local>& local : Sim->locals)
      {
	CoilRenderObj* obj = dynamic_cast<CoilRenderObj*>(&(*local));
	if (obj != NULL) 
	  obj->initRenderData(_window->getGLContext());
      }
    
    for (shared_ptr<Global>& global : Sim->globals)
      {
	CoilRenderObj* obj = dynamic_cast<CoilRenderObj*>(&(*global));
	if (obj != NULL) 
	  obj->initRenderData(_window->getGLContext());
      }

    _window->_updateDataSignal.connect<SVisualizer, &SVisualizer::updateRenderData>(this);
    updateRenderData();

    _lastUpdate = boost::posix_time::microsec_clock::local_time();
    /* Now request that the visualiser rescales to the best dimensions for the current system */
    _window->autoscaleView();

    dout << "Visualizer initialised" << std::endl;

    Sim->_sigParticleUpdate.connect<SVisualizer, &SVisualizer::particlesUpdated>(this);
  }