本文整理汇总了C++中KartProperties::getGraphicalYOffset方法的典型用法代码示例。如果您正苦于以下问题:C++ KartProperties::getGraphicalYOffset方法的具体用法?C++ KartProperties::getGraphicalYOffset怎么用?C++ KartProperties::getGraphicalYOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KartProperties
的用法示例。
在下文中一共展示了KartProperties::getGraphicalYOffset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadModels
/** 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);
#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);
}
}
float y_off = kart_properties.getGraphicalYOffset();
if(y_off!=0)
{
for (unsigned int i = 0; i < 4; i++)
m_wheel_graphics_position[i].setY(
m_wheel_graphics_position[i].getY() - y_off);
}
// 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 =
//.........这里部分代码省略.........