Beispiel #1
0
void Charge::drawLabel(QGLViewer& viewer, QFontMetrics& fontMetrics) 
{
   Vec pos(getPosition());
   Vec shift = viewer.camera()->position() - pos;
   shift.normalize();

   pos = pos + 1.05 * shift * getRadius(true);
   pos = viewer.camera()->projectedCoordinatesOf(pos);
   pos.x -= fontMetrics.width(m_label)/2;
   pos = viewer.camera()->unprojectedCoordinatesOf(pos);
   viewer.renderText(pos[0], pos[1], pos[2], m_label);
}
Beispiel #2
0
void CSceneGraph::exportPovrayFile(void *pwin, const char *fname)
{
	FILE *fp = fopen(fname, _WA_);
	assert(fp!=NULL);
	assert(pwin!=NULL);
	char povincfname[512], povincfullfname[512];

	//Assign the inc file name;
	CreateIncFileName(fname, povincfname, povincfullfname);
	
	//---------Main FILE---------------
	//
	ExportPovrayMaterial(fp);
	QGLViewer *pviewer = (QGLViewer*)pwin;
	qglviewer::Camera *pcamera = pviewer->camera();
	ExportPovrayCamera(pcamera, fp);

	fprintf(fp, "#include \"%s\"\n", povincfname);
	ExportPovrayObjects(*this, fp);
	fclose(fp);

	//---------MESH FILE---------------
	fp=fopen(povincfullfname, _WA_);
	assert(fp!=NULL);
	_exportPovrayMesh(fp);
	fclose(fp);
}
 Point_3 scene_point (const Point_2& p) const
 {
   QGLViewer* viewer = *QGLViewer::QGLViewerPool().begin();
   qglviewer::Camera* camera = viewer->camera();
   qglviewer::Vec vp (p.x(), p.y(), 0.1);
   qglviewer::Vec vsp = camera->unprojectedCoordinatesOf (vp);
   
   return Point_3 (vsp.x, vsp.y, vsp.z);
 }
bool Scene_polyhedron_shortest_path_item::get_mouse_ray(QMouseEvent* mouseEvent, Ray_3& outRay)
{
  bool found = false;
  
  QGLViewer* viewer = *QGLViewer::QGLViewerPool().begin();
  qglviewer::Camera* camera = viewer->camera();
  const qglviewer::Vec point = camera->pointUnderPixel(mouseEvent->pos(), found);
  
  if(found)
  {
    const qglviewer::Vec orig = camera->position();
    outRay = Ray_3(Point_3(orig.x, orig.y, orig.z), Point_3(point.x, point.y, point.z));
  }
  
  return found;
}