コード例 #1
0
void WorldEditorSelection::setCentroidPosition(bool useBoxCenter, const Point3F & pos)
{
   Point3F centroid;
   if( containsGlobalBounds() )
   {
      centroid = getCentroid();
   }
   else
   {
      centroid = useBoxCenter ? getBoxCentroid() : getCentroid();
   }

   offset(pos - centroid);
}
コード例 #2
0
OnMonitorCornersItem::cornersActions OnMonitorCornersItem::getMode(const QPointF &pos, int *corner)
{
    *corner = -1;
    if (polygon().count() != 4)
        return NoAction;

    QPainterPath mouseArea;
    qreal size = 12;
    if (getView())
        size /= m_view->matrix().m11();
    mouseArea.addRect(pos.x() - size / 2, pos.y() - size / 2, size, size);
    for (int i = 0; i < 4; ++i) {
        if (mouseArea.contains(polygon().at(i))) {
            *corner = i;
            return Corner;
        }
    }
    if (KdenliveSettings::onmonitoreffects_cornersshowcontrols()) {
        if (mouseArea.contains(getCentroid()))
            return Move;

        for (int i = 0; i < 4; ++i) {
            int j = (i + 1) % 4;
            if (mouseArea.contains(QLineF(polygon().at(i), polygon().at(j)).pointAt(.5))) {
                *corner = i;
                return MoveSide;
            }
        }
    }

    return NoAction;
}
コード例 #3
0
ファイル: WindowGroup.cpp プロジェクト: NREL/OpenStudio
  WindowGroupControl WindowGroup::windowGroupControl() const
  {
    boost::optional<double> largestArea;
    boost::optional<Point3d> centroid;
    boost::optional<Vector3d> outwardNormal;

    for (const auto & windowPolygon : m_windowPolygons){
      boost::optional<double> area = getArea(windowPolygon);
      if (area){
        if (!largestArea || (*area > *largestArea)){
          boost::optional<Point3d> tmpCentroid = getCentroid(windowPolygon);
          boost::optional<Vector3d> tmpOutwardNormal = getOutwardNormal(windowPolygon);
          if (tmpCentroid && tmpOutwardNormal){
            largestArea = area;
            centroid = tmpCentroid;
            outwardNormal = tmpOutwardNormal;
          }
        }
      }
    }

    WindowGroupControl result;
    result.largestArea = largestArea;
    result.centroid = centroid;
    result.outwardNormal = outwardNormal;

    return result;
  }
コード例 #4
0
ファイル: Polygon2D.cpp プロジェクト: Jornason/ofxToxiclibs
toxi::geom::Polygon2D * toxi::geom::Polygon2D::smooth( const float & amount, const float & baseWeight )
{
	Vec2D centroid = getCentroid();
	int num = vertices.size();
	std::vector<Vec2D> filtered;
	for (int i = 0, j = num - 1, k = 1; i < num; i++) {
		Vec2D a = vertices.at(i);
		Vec2D dir = vertices.at(j).sub( a ).addSelf( vertices.at(k).sub( a ))
			.addSelf(a.sub( centroid).scaleSelf(baseWeight));
		filtered.push_back(a.add(dir.scaleSelf(amount)));
		j++;
		if (j == num) {
			j = 0;
		}
		k++;
		if (k == num) {
			k = 0;
		}
	}
	vertices.clear();

	for( auto it = filtered.begin(); it != filtered.end(); ++it ) 
	{
		vertices.push_back( *it );
	}

	return this;
}
コード例 #5
0
void
PositionVector::scaleRelative(SUMOReal factor) {
    Position centroid = getCentroid();
    for (int i = 0; i < static_cast<int>(size()); i++) {
        (*this)[i] = centroid + (((*this)[i] - centroid) * factor);
    }
}
コード例 #6
0
void
PositionVector::scaleAbsolute(SUMOReal offset) {
    Position centroid = getCentroid();
    for (int i = 0; i < static_cast<int>(size()); i++) {
        (*this)[i] = centroid + (((*this)[i] - centroid) + offset);
    }
}
コード例 #7
0
ファイル: PlaceableObject.cpp プロジェクト: jzrake/VisBench
void PlaceableObject::mouseDrag(Point<int> mousePos)
{
    /* mouse pos in screen coordinates (-1, 1) */
    float mx = -1 + 2 * (mousePos.getX() / viewport->W);
    float my = +1 - 2 * (mousePos.getY() / viewport->H);
    
    glm::vec4 c0;
    glm::vec4 e0;
    getCentroid   (c0[0], c0[1], c0[2]);
    getEulerAngles(e0[0], e0[1], e0[2]);
    
    glm::vec4 vp = viewport->V * c0;
    glm::vec4 d0(mx, my, viewport->N, 1); /* 3d device coordinates of pick-ray endpoints */
    glm::vec4 d1(mx, my, viewport->F, 1);
    glm::vec4 x0 = viewport->inversePV * d0; x0 /= x0.w; /* 3d world coordinates of pick-ray endpoints */
    glm::vec4 x1 = viewport->inversePV * d1; x1 /= x1.w;
    
    //glm::mat4 R0 = glm::yawPitchRoll(e0[0], e0[1], e0[2]);
    //glm::vec4 zh = glm::inverse(glm::transpose(R0)) * glm::vec4(0,0,1,0);
    glm::vec4 zh;
    getDraggingPlane(zh[0], zh[1], zh[2]);

    /* parameter along the pick-ray where it intersects the model plane */
    float s = glm::dot(zh, c0 - x0) / glm::dot(zh, x1 - x0);
    
    glm::vec4 c1 = x0 + (x1 - x0) * s;
    setCentroid(c1[0], c1[1], c1[2]);
}
コード例 #8
0
/* TODO: deprecate this */
Coordinate*
CentroidArea::getCentroid() const
{
	Coordinate *cent = new Coordinate();
	getCentroid(*cent); // or return NULL on failure !
	return cent;
}
コード例 #9
0
ファイル: Mesh.cpp プロジェクト: budjmt/WreckEngine
vec3 Mesh::getGrossDims() {
	if (h_dims.x > 0) return h_dims;

	const auto centroid = getCentroid();

	// find the most distant point from the center
	auto max = _data.verts[0];
	auto maxDistSq = getDistSq(max, centroid);
	for (size_t i = 1, numVerts = _data.verts.size(); i < numVerts; ++i) {
		const auto v = _data.verts[i];
		const auto distSq = getDistSq(v, centroid);
		if (distSq > maxDistSq) { max = v; maxDistSq = distSq; }
	}

	// find the most distant point from THAT point
	auto min = _data.verts[0];
	maxDistSq = getDistSq(min, max);
	for (size_t i = 1, numVerts = _data.verts.size(); i < numVerts; ++i) {
		const auto v = _data.verts[i];
		const auto distSq = getDistSq(v, max);
		if (distSq > maxDistSq) { min = v; maxDistSq = distSq; }
	}

	h_dims = vec3(glm::length(max - min) * 0.5f);
	return h_dims;
}
コード例 #10
0
void OnMonitorCornersItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
{
    painter->setPen(QPen(Qt::yellow, 1, Qt::SolidLine));

    if (KdenliveSettings::onmonitoreffects_cornersshowlines())
        QGraphicsPolygonItem::paint(painter, option, widget);

    if (polygon().count() != 4)
        return;

    double baseSize = 1 / painter->worldTransform().m11();
    painter->setRenderHint(QPainter::Antialiasing);
    painter->setBrush(QBrush(isEnabled() ? Qt::yellow : Qt::red));
    double handleSize = 4  * baseSize;
    for (int i = 0; i < 4; ++i)
        painter->drawEllipse(polygon().at(i), handleSize, handleSize);

    if (KdenliveSettings::onmonitoreffects_cornersshowcontrols() && isEnabled()) {
        painter->setPen(QPen(Qt::red, 2, Qt::SolidLine));
        double toolSize = 6 * baseSize;
        // move tool
        QPointF c = getCentroid();
        painter->drawLine(QLineF(c - QPointF(toolSize, toolSize), c + QPointF(toolSize, toolSize)));
        painter->drawLine(QLineF(c - QPointF(-toolSize, toolSize), c + QPointF(-toolSize, toolSize)));

        // move side tools (2 corners at once)
        for (int i = 0; i < 4; ++i) {
            int j = (i + 1) % 4;
            QPointF m = QLineF(polygon().at(i), polygon().at(j)).pointAt(.5);
            painter->drawRect(QRectF(-toolSize / 2., -toolSize / 2., toolSize, toolSize).translated(m));
        }
    }
}
コード例 #11
0
ファイル: TriMesh.cpp プロジェクト: JoshChristie/displaz
//------------------------------------------------------------------------------
// TriMesh implementation
bool TriMesh::loadFile(QString fileName, size_t /*maxVertexCount*/)
{
    // maxVertexCount is ignored - not sure there's anything useful we can do
    // to respect it when loading a mesh...
    PlyLoadInfo info;
    if (!loadPlyFile(fileName, info))
        return false;
    setFileName(fileName);
    V3d offset = V3d(info.offset[0], info.offset[1], info.offset[2]);
    setOffset(offset);
    setCentroid(getCentroid(offset, info.verts));
    setBoundingBox(getBoundingBox(offset, info.verts));
    m_verts.swap(info.verts);
    m_colors.swap(info.colors);
    m_texcoords.swap(info.texcoords);
    m_triangles.swap(info.triangles);
    m_edges.swap(info.edges);
    if (!info.textureFileName.isEmpty())
    {
        QImage image;
        if (image.load(info.textureFileName))
            m_texture.reset(new Texture(image));
        else
            g_logger.warning("Could not load texture %s for model %s", info.textureFileName, fileName);
    }
    //makeSmoothNormals(m_normals, m_verts, m_triangles);
    //makeEdges(m_edges, m_triangles);
    return true;
}
コード例 #12
0
ファイル: polyEditable.cpp プロジェクト: csugrue/ensanche
void polyEditable::mouseDragged(ofMouseEventArgs& event)
{
	if( !bEnabled ) return;
	
	
	if(event.button != 0 ) setMode(POLY_EDIT_MODE_MOVE_ALL);
	//else if(event.button != 0 )				setMode(POLY_EDIT_MODE_ROTATE);
	else if( bUseRotation && !bTempMode)					setMode(POLY_EDIT_MODE_MOVE_ALL);
	
	ofPoint m = getMouseAltered( ofPoint(event.x,event.y) );	
	
	if( mode == POLY_EDIT_MODE_MOVE_PTS )
	{
		if(selectedPoint >= 0)
			pts[ selectedPoint ].set( m.x, m.y);
	
	}else if( mode == POLY_EDIT_MODE_MOVE_ALL )
	{
		
		ofPoint diff = ofPoint( (m.x-lastCenter.x)-moveOffSet.x,(m.y-lastCenter.y)-moveOffSet.y);
		
		if( diff.x == diff.x && diff.y == diff.y )
			moveAllPointsBy( diff );
		
		lastCenter = getCentroid();
		
	}else if( mode == POLY_EDIT_MODE_ROTATE)
	{
		if(bUseRotation) rotation += .5*(event.y-lastMouse.y);
		else			 rotate(.5*(event.y-lastMouse.y));
	}
	
	lastMouse.set( event.x, event.y );

}
コード例 #13
0
ファイル: Polygon2D.cpp プロジェクト: Jornason/ofxToxiclibs
toxi::geom::Polygon2D * toxi::geom::Polygon2D::scaleSize( const float & x, const float & y )
{
	Vec2D centroid = getCentroid();
	for (Vec2D v : vertices) {
		v.subSelf(centroid).scaleSelf(x, y).addSelf( centroid );
	}
	return this;
}
コード例 #14
0
ファイル: Polygon2D.cpp プロジェクト: Jornason/ofxToxiclibs
toxi::geom::Polygon2D * toxi::geom::Polygon2D::center( Vec2D & origin )
{
	Vec2D centroid = getCentroid();
	Vec2D delta = ( !origin.isZeroVector() ) ? origin.sub( centroid ) : centroid.invert();
	for( Vec2D v : vertices )
	{
		v.addSelf( delta );
	}
	return this;
}
コード例 #15
0
void polyFixWidth::draw()
{
	makeRectangle();
	
	ofFill();
	ofSetColor(fillColor.r, fillColor.g, fillColor.b, fillColor.a);
	
	// draw rect
	if( rectPts.size() > 0 )
	{
		ofBeginShape();
		for( int i = 0; i < rectPts.size(); i++)
			ofVertex(rectPts[i].x, rectPts[i].y);
		
		ofVertex(rectPts[0].x, rectPts[0].y);
		ofEndShape();
	}
	
	
	ofNoFill();
	ofSetColor(strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a);
	
	if( rectPts.size() > 0 )
	{
		ofBeginShape();
		for( int i = 0; i < rectPts.size(); i++)
			ofVertex(rectPts[i].x, rectPts[i].y);
		//ofVertex(rectPts[0].x, rectPts[0].y);
		ofEndShape(true);
	}
	
	// draw end pts
	//polyEditable::draw();
	for( int i = 0; i < pts.size(); i++)
	{
		if( i == selectedPoint && bEnabled ) ofCircle(pts[i].x, pts[i].y, 4);
		if(bEnabled) ofCircle(pts[i].x, pts[i].y, 1);
	}
	
	
	// draw line
	if( pts.size() > 1 && pts.size() < 2 )
	{
		ofSetColor(255,0,0,255);
		//ofLine( pts[0].x, pts[0].y, pts[1].x, pts[1].y);
	}
	
	if( pts.size() == 2 )
	{
		ofPoint c = getCentroid();
		ofCircle(c.x,c.y,2);
	}
	
	
}
コード例 #16
0
void testApp::drawPointCloud() {
	int w = 640;
	int h = 480;
    int threshold_close=500;
    int threshold_far=1000;
    
    int ratio=200;
	ofMesh mesh;
	mesh.setMode(OF_PRIMITIVE_POINTS);
	int step = 2;
	for(int y = 0; y < h; y += step) {
		for(int x = 0; x < w; x += step) {
            //
			if((kinect.getDistanceAt(x, y) > threshold_close)&&(kinect.getDistanceAt(x, y) < threshold_far)) {
               
                 float distc=ofDist(x,y,xini,yini);
                
                //look for hole 
                if (distc < ratio){
                    
                    float z=kinect.getDistanceAt(x, y);
                    // drill the hole around the center
                     mesh.addColor(distc/100);
                    float z2=z+20*(ratio/(distc+00000000.1));
                    ofVec3f pos(x - w/ 2, y - h / 2, z2);
                    mesh.addVertex(pos);
                    }
                
                else{
                     mesh.addColor(255);
                    float z=kinect.getDistanceAt(x, y);
                    ofVec3f pos2(x - w/ 2, y - h / 2, z);
                    mesh.addVertex(pos2);


                }
				
                
			}
		}
	}
    
    ofVec3f centroid = getCentroid(mesh);
    xini= centroid.x+w/2;
    yini=centroid.y+h/2;
    	glPointSize(1);
	ofPushMatrix();
	// the projected points are 'upside down' and 'backwards' 
	ofScale(1, -1, -1);
	ofTranslate(0, 0, -1000); // center the points a bit
	glEnable(GL_DEPTH_TEST);
	mesh.drawVertices();
	glDisable(GL_DEPTH_TEST);
	ofPopMatrix();
}
コード例 #17
0
ファイル: Geometry.cpp プロジェクト: asapnet/geos
/*public*/
Point*
Geometry::getCentroid() const
{
	Coordinate centPt;
	if ( ! getCentroid(centPt) ) return NULL;

	// We don't use createPointFromInternalCoord here
	// because ::getCentroid() takes care about rounding
	Point *pt=getFactory()->createPoint(centPt);
	return pt;
}
コード例 #18
0
void SVGCreater(polygon& poly, boost::geometry::svg_mapper<point_type>& mapper, std::string color)
{
  std::string svg_color = "fill-opacity:0.3;fill:rgb("
      + color + ");stroke:rgb("
      + color + ");stroke-width:2";

  mapper.add(poly);
  mapper.map(poly, svg_color);
  std::cout << "Area: " << getArea(poly) << "\n";
  std::cout << "Centroid: " << boost::geometry::dsv(getCentroid(poly)) << "\n";
}
コード例 #19
0
ファイル: MathematicalShape.cpp プロジェクト: sdp0et/gtp
Vector MathematicalShape::getColor( const Vector& pointOnLight, ColorIndex colorIndex )
{
  // need (theta,azimuth) angle to POINT ON LIGHT
  Vector sphCoord = pointOnLight - getCentroid() ;
    
  // no need to normalize, only using elevation/azimuth
  SVector sp = sphCoord.toSpherical() ;
    
  // light color for that point we are hitting (matters for cubemaps, math lights)
  return getColor( sp.tElevation, sp.pAzimuth, colorIndex ) ;
}
コード例 #20
0
ファイル: NavMesh.cpp プロジェクト: nstbayless/sdlgame
NavPoly* NavMesh::getNearestPolygon(point_t coord) {
	NavPoly* closest = nullptr;
	float minDist = FLT_MAX;
	for (auto it_p = polygon.begin(); it_p != polygon.end(); it_p++) {
		float trial_dist = it_p->getCentroid().getDistance(coord);
		if (trial_dist < minDist) {
			minDist = trial_dist;
			closest=&*it_p;
		}
	}
	return closest;
}
コード例 #21
0
vector<CCPoint> GestureRecognizer::rotatePointsBy(vector<CCPoint> points, float w) {
	vector<CCPoint> newPoints;
	CCPoint centroid = getCentroid(points);
	float cosw = cos(w);
	float sinw = sin(w);
	for(int i=0; i<points.size(); i++) {
		float qx = (points[i].x - centroid.x) * cosw - (points[i].y - centroid.y) * sinw + centroid.x;
		float qy = (points[i].x - centroid.x) * sinw + (points[i].y - centroid.y) * cosw + centroid.y;
		newPoints.push_back(CCPoint(qx, qy));
	}
	return newPoints;
}
コード例 #22
0
vector<CCPoint> GestureRecognizer::translatePointsTo(vector<CCPoint> points, CCPoint kPoint) {
	CCPoint centroid = getCentroid(points);
	
	vector<CCPoint> newPoints;

	for(int i=0; i<points.size(); i++) {
		float qx = points[i].x + kPoint.x - centroid.x;
		float qy = points[i].y + kPoint.y - centroid.y;
		newPoints.push_back(CCPoint(qx, qy));
	}
	return newPoints;
}
コード例 #23
0
void SVGCreater(std::vector<polygon>& poly_, const char* path)
{
  std::ofstream svg(path);
  boost::geometry::svg_mapper<point_type> mapper(svg, 400, 400);

  for (std::vector<polygon>::iterator it = poly_.begin(); it != poly_.end(); it++)
  {
    mapper.add(*it);
    mapper.map(*it, "fill-opacity:0.3;fill:rgb(51,51,153);stroke:rgb(51,51,153);stroke-width:2");
    std::cout << "Area: " << getArea(*it) << "\n";

    std::cout << "Centroid: " << boost::geometry::dsv(getCentroid(*it)) << "\n";
  }

}
コード例 #24
0
ファイル: NexusGame.cpp プロジェクト: AnsonX10/bitfighter
void NexusZone::render() const
{
#ifndef ZAP_DEDICATED
    GameType *gameType = getGame() ? getGame()->getGameType() : NULL;
    NexusGameType *nexusGameType = NULL;

    if(gameType && gameType->getGameTypeId() == NexusGame)
        nexusGameType = static_cast<NexusGameType *>(gameType);

    bool isOpen = nexusGameType && nexusGameType->isNexusOpen();
    F32 glowFraction = gameType ? gameType->mZoneGlowTimer.getFraction() : 0;

    GameObjectRender::renderNexus(getOutline(), getFill(), getCentroid(), getLabelAngle(), isOpen, glowFraction);
#endif
}
コード例 #25
0
ファイル: polyEditable.cpp プロジェクト: csugrue/ensanche
void polyEditable::mousePressed(ofMouseEventArgs& event)
{
	
	if( !bEnabled ) return;
	
	lastMouse.set( event.x, event.y );
	ofPoint m = getMouseAltered( ofPoint(event.x,event.y) );//ofPoint( (event.x-offSet.x)*invScale, (event.y-offSet.y)*invScale);

	int modifier = glutGetModifiers();

	if( modifier == GLUT_ACTIVE_SHIFT)
	{
		setMode(POLY_EDIT_MODE_MOVE_PTS);//,true);
	}else if( modifier == GLUT_ACTIVE_CTRL )
	{
		setMode(POLY_EDIT_MODE_ROTATE,true);
	}else if( mode == POLY_EDIT_MODE_MOVE_PTS && bTempMode )
		setMode(prevMode);
	else if( event.button == 0  ) setMode(POLY_EDIT_MODE_ADD_PTS);
	//else setMode(POLY_EDIT_MODE_MOVE_ALL);
	
	
	if( mode == POLY_EDIT_MODE_ADD_PTS && event.button == 0 )
	{
		
		//--- add point here
		addPoint( ofPoint(m.x, m.y) );
	
	}else if( mode == POLY_EDIT_MODE_MOVE_PTS)
	{
		selectedPoint = -1;
		
		//--- select points, chooses first closest (must use tab to go next point for close points)
		for( int i = 0; i < pts.size(); i++)
		{
			if( abs( (int)(m.x-pts[i].x) ) < selectDist && abs( (int)(m.y-pts[i].y) ) < selectDist )
			{
				selectedPoint = i;
				break;
			}
		}
		
		
	}
	
	lastCenter = getCentroid();
	moveOffSet.set(m.x-lastCenter.x,m.y-lastCenter.y);
}
コード例 #26
0
ファイル: polygon.cpp プロジェクト: bitfighter/bitfighter
void PolygonObject::renderEditor(F32 currentScale, bool snappingToWallCornersEnabled, bool renderVertices) const
{
#ifndef ZAP_DEDICATED
   if(isSelected() || isLitUp())
      renderPolyHighlight();

   if(renderVertices)
   {
      GameObjectRender::renderPolyLineVertices(this, snappingToWallCornersEnabled, currentScale);

      // Draw a snap target vertex at the centroid
      if(snappingToWallCornersEnabled && !isSelected())
         GameObjectRender::renderSmallSolidVertex(currentScale, getCentroid(), true);
   }
#endif
}
コード例 #27
0
ファイル: mesh.cpp プロジェクト: gphysics/displaz
//------------------------------------------------------------------------------
// TriMesh implementation
bool TriMesh::loadFile(QString fileName, size_t /*maxVertexCount*/)
{
    // maxVertexCount is ignored - not sure there's anything useful we can do
    // to respect it when loading a mesh...
    PlyLoadInfo info;
    if (!loadPlyFile(fileName, info))
        return false;
    setFileName(fileName);
    V3d offset = V3d(info.offset[0], info.offset[1], info.offset[2]);
    setOffset(offset);
    setCentroid(getCentroid(offset, info.verts));
    setBoundingBox(getBoundingBox(offset, info.verts));
    m_verts.swap(info.verts);
    m_colors.swap(info.colors);
    m_faces.swap(info.faces);
    m_edges.swap(info.edges);
    //makeSmoothNormals(m_normals, m_verts, m_faces);
    //makeEdges(m_edges, m_faces);
    return true;
}
コード例 #28
0
void polyFixWidth::setPerpendiculars(float len )
{
	if( pts.size() >= 2 )
	{
		// create vector for each end point 
		ofxVec2f ptA = ofxVec2f(pts[0].x,pts[0].y);
		ofxVec2f ptB = ofxVec2f(pts[1].x,pts[1].y);
		
		// calculate perpendicular
		ofxVec2f diffVec = ptA-ptB;
		
		diffVec = diffVec.getNormalized();
		ofxVec2f pp = diffVec.getPerpendicular();
		
		ofPoint c = getCentroid();
		ppA.set( c.x + len * pp.x, c.y + len * pp.y);
		ppB.set( c.x - len * pp.x, c.y - len * pp.y);
	}
	
}
コード例 #29
0
ファイル: FaceItem.cpp プロジェクト: AresAndy/ufoai
void FaceItem::snapSelectedToGrid(float grid) {
	if (_selected) {
		Vector2 centroid = getCentroid();

		Vector2 snapped(
			float_snapped(centroid[0], grid),
			float_snapped(centroid[1], grid)
		);

		Vector3 translation;
		translation[0] = snapped[0] - centroid[0];
		translation[1] = snapped[1] - centroid[1];

		Matrix4 matrix = Matrix4::getTranslation(translation);

		// Do the transformation
		transform(matrix);
	}

	// Let the base class call the method on our children
	TexToolItem::snapSelectedToGrid(grid);
}
コード例 #30
0
ファイル: main.cpp プロジェクト: GiantMonsterCo/glslViewer
void setup() {
    glEnable(GL_DEPTH_TEST);
    glFrontFace(GL_CCW);
    
    //  Load Geometry
    //
    if ( iGeom == -1 ){
        vbo = rect(0.0,0.0,1.0,1.0).getVbo();
    } else {
        Mesh model;
        model.load(files[iGeom].path);
        vbo = model.getVbo();
        glm::vec3 toCentroid = getCentroid(model.getVertices());
        // model_matrix = glm::scale(glm::vec3(0.001));
        model_matrix = glm::translate(-toCentroid);
    }

    //  Build shader;
    //
    if ( iFrag != -1 ) {
        fragSource = "";
        if(!loadFromPath(files[iFrag].path, &fragSource)) {
            return;
        }
    } else {
        fragSource = vbo->getVertexLayout()->getDefaultFragShader();
    }

    if ( iVert != -1 ) {
        vertSource = "";
        loadFromPath(files[iVert].path, &vertSource);
    } else {
        vertSource = vbo->getVertexLayout()->getDefaultVertShader();
    }    
    shader.load(fragSource,vertSource);
    
    cam.setViewport(getWindowWidth(),getWindowHeight());
    cam.setPosition(glm::vec3(0.0,0.0,-3.));
}