// ---------------------------------------------------------------------------- bool KartProperties::operator<(const KartProperties &other) const { PlayerProfile *p = PlayerManager::getCurrentPlayer(); bool this_is_locked = p->isLocked(getIdent()); bool other_is_locked = p->isLocked(other.getIdent()); if (this_is_locked == other_is_locked) { return getName() < other.getName(); } else return other_is_locked; return true; } // operator<
/** Returns a unique identifier for this kart (name of the directory the * kart was loaded from). */ const std::string& getIdent() const {return m_kart_properties->getIdent();}
/** Returns a name to be displayed for this kart. */ virtual const irr::core::stringw& getName() const { return m_kart_properties->getName(); }
/** Returns the maximum steering angle for this kart, which depends on the * speed. */ float getMaxSteerAngle () const { return m_kart_properties->getMaxSteerAngle(getSpeed()); }
/** Returns the time till full steering is reached for this kart. */ float getTimeFullSteer() const { return m_kart_properties->getTimeFullSteer(); }
/** Returns the strenght of the brakes for this kart. */ float getBrakeFactor() const {return m_kart_properties->getBrakeFactor();}
/** Returns the maximum engine power for this kart. */ float getMaxPower () const {return m_kart_properties->getMaxPower(); }
/** Returns the current mass of this kart, including any attachment this * kart might have. */ float getMass() const { return m_kart_properties->getMass() + m_attachment->weightAdjust();}
/** Returns the color used for this kart. */ const video::SColor &getColor() const {return m_kart_properties->getColor();}
/** Sets that the view is blocked by a plunger. The duration depends on * the difficulty, see KartPorperties getPlungerInFaceTime. */ void blockViewWithPlunger() { m_view_blocked_by_plunger = m_kart_properties->getPlungerInFaceTime();}
/** Loads the 3d model and all wheels. */ bool KartModel::loadModels(const KartProperties &kart_properties) { assert(m_is_master); std::string full_path = kart_properties.getKartDir()+m_model_filename; m_mesh = irr_driver->getAnimatedMesh(full_path); if(!m_mesh) { Log::error("Kart_Model", "Problems loading mesh '%s' - kart '%s' will" "not be available.", full_path.c_str(), kart_properties.getIdent().c_str()); return false; } m_mesh->grab(); irr_driver->grabAllTextures(m_mesh); Vec3 kart_min, kart_max; MeshTools::minMax3D(m_mesh->getMesh(m_animation_frame[AF_STRAIGHT]), &kart_min, &kart_max); // Test if kart model support colorization for (u32 i = 0; i < m_mesh->getMeshBufferCount(); i++) { scene::IMeshBuffer* mb = m_mesh->getMeshBuffer(i); Material* material = material_manager->getMaterialFor(mb ->getMaterial().getTexture(0), mb); m_support_colorization = m_support_colorization || material->isColorizable(); } #undef MOVE_KART_MESHES #ifdef MOVE_KART_MESHES // Kart models are not exactly centered. The following code would // transform the mesh so that they are properly centered, but it // would also mean all location relative to the original kart's // center (wheel position, emitter, hat) would need to be modified. scene::IMeshManipulator *mani = irr_driver->getVideoDriver()->getMeshManipulator(); Vec3 offset_from_center = -0.5f*(kart_max+kart_min); offset_from_center.setY(-kart_min.getY()); offset_from_center.setY(0); core::matrix4 translate(core::matrix4::EM4CONST_IDENTITY); translate.setTranslation(offset_from_center.toIrrVector()); mani->transform(m_mesh, translate); MeshTools::minMax3D(m_mesh->getMesh(m_animation_frame[AF_STRAIGHT]), &kart_min, &kart_max); #endif m_kart_highest_point = kart_max.getY(); m_kart_lowest_point = kart_min.getY(); // Load the speed weighted object models. We need to do that now because it can affect the dimensions of the kart for(size_t i=0 ; i < m_speed_weighted_objects.size() ; i++) { SpeedWeightedObject& obj = m_speed_weighted_objects[i]; std::string full_name = kart_properties.getKartDir()+obj.m_name; obj.m_model = irr_driver->getAnimatedMesh(full_name); // Grab all textures. This is done for the master only, so // the destructor will only free the textures if a master // copy is freed. irr_driver->grabAllTextures(obj.m_model); // Update min/max Vec3 obj_min, obj_max; MeshTools::minMax3D(obj.m_model, &obj_min, &obj_max); obj_min += obj.m_position; obj_max += obj.m_position; kart_min.min(obj_min); kart_max.max(obj_max); } Vec3 size = kart_max-kart_min; m_kart_width = size.getX(); m_kart_height = size.getY(); m_kart_length = size.getZ(); // Now set default some default parameters (if not defined) that // depend on the size of the kart model (wheel position, center // of gravity shift) for(unsigned int i=0; i<4; i++) { if(m_wheel_graphics_position[i].getX()==UNDEFINED) { m_wheel_graphics_position[i].setX( ( i==1||i==3) ? -0.5f*m_kart_width : 0.5f*m_kart_width ); m_wheel_graphics_position[i].setY(0); m_wheel_graphics_position[i].setZ( (i<2) ? 0.5f*m_kart_length : -0.5f*m_kart_length); } } // Load the wheel models. This can't be done early, since the default // values for the graphical position must be defined, which in turn // depend on the size of the model. for(unsigned int i=0; i<4; i++) { // For kart models without wheels. if(m_wheel_filename[i]=="") continue; std::string full_wheel = kart_properties.getKartDir()+m_wheel_filename[i]; m_wheel_model[i] = irr_driver->getMesh(full_wheel); // Grab all textures. This is done for the master only, so // the destructor will only free the textures if a master // copy is freed. irr_driver->grabAllTextures(m_wheel_model[i]); } // for i<4 return true; } // loadModels
/** Returns a name to be displayed for this kart. */ virtual const wchar_t* getName() const { return m_kart_properties->getName(); }