bool OBJFileReader::load(const char *filename, int n) {
  // Open OBJ file
  std::ifstream OBJFile(filename);
  std::cout << "trying to load obj" << std::endl;
  // Original load
  if(n==1) {
    if (!OBJFile.is_open()) {
      std::cerr << "Could not open " << filename << std::endl;
      return false;
    }
        
    // Extract vertices and indices
    std::string line;
    glm::vec3 vertex;
    uint32_t vertexIndex0, vertexIndex1, vertexIndex2;
    while (!OBJFile.eof()) {
      std::getline(OBJFile, line);
      if (line.substr(0, 2) == VERTEX_LINE) {
	std::istringstream vertexLine(line.substr(2));
	vertexLine >> vertex.x;
	vertexLine >> vertex.y;
	vertexLine >> vertex.z;
	mVertices.push_back(vertex);
      }
      else if (line.substr(0, 2) == FACE_LINE) {
	std::istringstream faceLine(line.substr(2));
	faceLine >> vertexIndex0;
	faceLine >> vertexIndex1;
	faceLine >> vertexIndex2;
	mIndices.push_back(vertexIndex0 - 1);
	mIndices.push_back(vertexIndex1 - 1);
	mIndices.push_back(vertexIndex2 - 1);
      }
ArticulatedCrane::ArticulatedCrane(SceneRenderer* sr, Vector3 location)
{
	// set the variables for movement
	dtheta = 2.0f;
	dx = 0.2f;
	dy = 0.2f;
	outmax = 12;
	downmax = 8;
	basevector = location;
	loaddistance = loadheight = 0;
	loaddirout = loaddirdown = true;
	// get the renderable models
	basemodel = OBJFile("./resources/models/crane_base.obj").getModel();
	armmodel = OBJFile("./resources/models/crane_arm.obj").getModel();
	loadmodel = OBJFile("./resources/models/crane_load.obj").getModel();
	// create the material and set properties
	auto mat = make_shared<Material>();
    mat->setShaderSet(
			CgSingleton::getSingleton().shaderSetMap["deferredTexture"]);
	basemodel->setMaterial(mat);
	armmodel->setMaterial(mat);
	loadmodel->setMaterial(mat);
	// create the base at the base location
	basesn = make_shared<SceneNode>(basevector);
	basesn->addRenderable(basemodel);
	// create the arm with an offset from the base
	armvector = Vector3(5.0f, 12.0f, 0.0f);
	armsn = make_shared<SceneNode>(armvector);
	armsn->setParent(basesn);
	armsn->addRenderable(armmodel);
	// create the load with an offset from the base
	loadvector = Vector3(-10.0f, 9.5f, 0.0f);
	loadsn = make_shared<SceneNode>(loadvector);
	loadsn->setParent(basesn);
	loadsn->addRenderable(loadmodel);
	// add to the sr tree
	sr->getSceneNodes().push_back(basesn);
}