int SSG_Planet::load(const XMLReader& reader) { //SFG::Util::printLog(SFG::Util::Development, __FILE__, __LINE__, "Still to do"); //Load values accordingly this->m_name = reader.getValue("name."); bool real = false; this->setMass(PE::Mass(reader.asDouble("mass/", real))); if(!real) { //Failed to load mass SFG::Util::printLog(SFG::Util::Error, __FILE__, __LINE__, "Failed to load Mass"); } sf::FloatRect r = reader.asFloatRect("PosAndVel/", real); if(!real) { //Failed to load pos and Velocity SFG::Util::printLog(SFG::Util::Error, __FILE__, __LINE__, "Failed to load PosAndVel"); } //this->setPosition(r.left, r.top); this->setPosition(mpf_class(r.left), mpf_class(r.top)); this->setVelocity(PE::Velocity(r.width, r.height)); auto radius = reader.asDouble("radius/", real); if(!real) { SFG::Util::printLog(SFG::Util::Error, __FILE__, __LINE__, "Failed to get radius for planet %s", this->m_name.toAnsiString().c_str()); } this->getShape().setRadius(radius); SFG::FloatRect rect(this->getShape().getLocalBounds()); this->getShape().setOrigin(rect.center()); m_planet_surface.reset(new SSG_PlanetSurface(radius)); m_planet_surface->load(); //Get Moons reader.for_all("Moon", [=](const XMLGroup* g){ SFG::Pointer<SSG_Planet> ptr(new SSG_Planet()); ptr->m_parentSys = this->m_parentSys; ptr->setGuiDesktop(this->desktop()); int ret = ptr->load(XMLReader(*g)); if(ret != 0) { SFG::Util::printLog(SFG::Util::Error, __FILE__, __LINE__, "Failed to load moon"); return; } printf("Position: %f + %f | %f + %f\n", getShape().getPosition().x , ptr->getShape().getPosition().x, getShape().getPosition().y, ptr->getShape().getPosition().y); //Correct relative values //ptr->setPosition(getShape().getPosition().x + ptr->getShape().getPosition().x, // getShape().getPosition().y + ptr->getShape().getPosition().y); ptr->setPosition(x() + ptr->x(), y() + ptr->y()); ptr->setVelocity(getVelocity() + ptr->getVelocity()); //Add to system this->m_parentSys->addSpecificToSystem(ptr); SFG::Util::printLog(SFG::Util::Information, __FILE__, __LINE__, "Moon \"%s\" has been added", ptr->getName().toAnsiString().c_str()); }); //TESTING this->getShape().setFillColor(sf::Color(255, 255, 255)); //!TESTING return 0; }