本文整理汇总了C++中LODNode类的典型用法代码示例。如果您正苦于以下问题:C++ LODNode类的具体用法?C++ LODNode怎么用?C++ LODNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LODNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getMesh
// ----------------------------------------------------------------------------
scene::IAnimatedMeshSceneNode* TrackObject::getMesh()
{
if (getPresentation<TrackObjectPresentationLOD>())
{
LODNode* ln = dynamic_cast<LODNode*>
(getPresentation<TrackObjectPresentationLOD>()->getNode());
if (ln && !ln->getAllNodes().empty())
{
scene::IAnimatedMeshSceneNode* an =
dynamic_cast<scene::IAnimatedMeshSceneNode*>
(ln->getFirstNode());
if (an)
{
return an;
}
}
}
else if (getPresentation<TrackObjectPresentationMesh>())
{
scene::IAnimatedMeshSceneNode* an =
dynamic_cast<scene::IAnimatedMeshSceneNode*>
(getPresentation<TrackObjectPresentationMesh>()->getNode());
if (an)
{
return an;
}
}
Log::debug("TrackObject", "No animated mesh");
return NULL;
} // getMesh
示例2: finishedRace
/** Called when the kart finished the race. It will force the highest LOD
* for the kart, since otherwise the end camera can be far away (due to
* zooming) and show non-animated karts.
*/
void KartModel::finishedRace()
{
// Force the animated model, independent of actual camera distance.
LODNode *lod = dynamic_cast<LODNode*>(m_kart->getNode());
if (lod)
lod->forceLevelOfDetail(0);
} // finishedRace
示例3: loadTextureToGPU
bool loadTextureToGPU(const LODNode& lodNode, const DataSource& dataSource,
const TexturePool& texturePool,
const ConstDataObjectPtr& data) const
{
#ifdef LIVRE_DEBUG_RENDERING
std::cout << "Upload " << lodNode.getNodeId().getLevel() << ' '
<< lodNode.getRelativePosition() << " to "
<< _textureState.textureId << std::endl;
#endif
const Vector3ui& overlap = dataSource.getVolumeInfo().overlap;
const Vector3ui& voxSizeVec = lodNode.getBlockSize() + overlap * 2;
_textureState.bind();
glTexSubImage3D(GL_TEXTURE_3D, 0, 0, 0, 0, voxSizeVec[0], voxSizeVec[1],
voxSizeVec[2], texturePool.getFormat(),
texturePool.getTextureType(), data->getDataPtr());
const GLenum glErr = glGetError();
if (glErr != GL_NO_ERROR)
{
LBERROR << "Error loading the texture into GPU, error number : "
<< glErr << std::endl;
return false;
}
return true;
}
示例4: TrackObjectPresentationSceneNode
// ----------------------------------------------------------------------------
TrackObjectPresentationParticles::TrackObjectPresentationParticles(
const XMLNode& xml_node,
scene::ISceneNode* parent)
: TrackObjectPresentationSceneNode(xml_node)
{
m_emitter = NULL;
m_lod_emitter_node = NULL;
std::string path;
xml_node.get("kind", &path);
int clip_distance = -1;
xml_node.get("clip_distance", &clip_distance);
xml_node.get("conditions", &m_trigger_condition);
bool auto_emit = true;
xml_node.get("auto_emit", &auto_emit);
m_delayed_stop = false;
m_delayed_stop_time = 0.0;
#ifndef SERVER_ONLY
try
{
ParticleKind* kind = ParticleKindManager::get()->getParticles(path);
if (kind == NULL)
{
throw std::runtime_error(path + " could not be loaded");
}
ParticleEmitter* emitter = new ParticleEmitter(kind, m_init_xyz, parent);
if (clip_distance > 0)
{
scene::ISceneManager* sm = irr_driver->getSceneManager();
scene::ISceneNode* sroot = sm->getRootSceneNode();
LODNode* lod = new LODNode("particles", !parent ? sroot : parent, sm);
lod->add(clip_distance, (scene::ISceneNode*)emitter->getNode(), true);
m_node = lod;
m_lod_emitter_node = lod;
m_emitter = emitter;
}
else
{
m_node = emitter->getNode();
m_emitter = emitter;
}
if (m_trigger_condition.size() > 0 || !auto_emit)
{
m_emitter->setCreationRateAbsolute(0.0f);
}
}
catch (std::runtime_error& e)
{
Log::warn ("Track", "Could not load particles '%s'; cause :\n %s",
path.c_str(), e.what());
}
#endif
} // TrackObjectPresentationParticles
示例5: assert
Item::Item(ItemType type, const Vec3& xyz, const Vec3& normal,
scene::IMesh* mesh, scene::IMesh* lowres_mesh)
{
assert(type != ITEM_TRIGGER); // use other constructor for that
m_distance_2 = 1.2f;
initItem(type, xyz);
m_original_rotation = shortestArcQuat(Vec3(0, 1, 0), normal);
m_rotation_angle = 0.0f;
m_original_mesh = mesh;
m_original_lowmesh = lowres_mesh;
m_listener = NULL;
LODNode* lodnode = new LODNode("item",
irr_driver->getSceneManager()->getRootSceneNode(),
irr_driver->getSceneManager());
scene::IMeshSceneNode* meshnode =
irr_driver->addMesh(mesh, StringUtils::insertValues("item_%i", (int)type));
if (lowres_mesh != NULL)
{
lodnode->add(35, meshnode, true);
scene::IMeshSceneNode* meshnode =
irr_driver->addMesh(lowres_mesh,
StringUtils::insertValues("item_lo_%i", (int)type));
lodnode->add(100, meshnode, true);
}
else
{
lodnode->add(100, meshnode, true);
}
m_node = lodnode;
//m_node = irr_driver->addMesh(mesh);
#ifdef DEBUG
std::string debug_name("item: ");
debug_name += m_type;
m_node->setName(debug_name.c_str());
#endif
World::getWorld()->getTrack()->adjustForFog(m_node);
m_node->setAutomaticCulling(scene::EAC_FRUSTUM_BOX);
m_node->setPosition(xyz.toIrrVector());
Vec3 hpr;
hpr.setHPR(m_original_rotation);
m_node->setRotation(hpr.toIrrHPR());
m_node->grab();
} // Item(type, xyz, normal, mesh, lowres_mesh)
示例6: TrackObjectPresentationSceneNode
TrackObjectPresentationParticles::TrackObjectPresentationParticles(const XMLNode& xml_node, scene::ISceneNode* parent) :
TrackObjectPresentationSceneNode(xml_node)
{
m_emitter = NULL;
m_lod_emitter_node = NULL;
std::string path;
xml_node.get("kind", &path);
int clip_distance = -1;
xml_node.get("clip_distance", &clip_distance);
xml_node.get("conditions", &m_trigger_condition);
try
{
ParticleKind* kind = ParticleKindManager::get()->getParticles( path.c_str() );
if (kind == NULL)
{
throw std::runtime_error(path + " could not be loaded");
}
ParticleEmitter* emitter = new ParticleEmitter(kind, m_init_xyz, parent);
if (clip_distance > 0)
{
scene::ISceneManager* sm = irr_driver->getSceneManager();
scene::ISceneNode* sroot = sm->getRootSceneNode();
LODNode* lod = new LODNode("particles", parent == NULL ? sroot : parent, sm);
lod->add(clip_distance, (scene::ISceneNode*)emitter->getNode(), true);
m_node = lod;
m_lod_emitter_node = lod;
m_emitter = emitter;
}
else
{
m_node = emitter->getNode();
m_emitter = emitter;
}
if (m_trigger_condition.size() > 0)
{
m_emitter->setCreationRateAbsolute(0.0f);
}
}
catch (std::runtime_error& e)
{
fprintf(stderr, "[Track] WARNING: Could not load particles '%s'; cause :\n %s", path.c_str(), e.what());
}
}
示例7: LODNode
void Character::initNodePath(Player *player,
CollisionTraverser *traverser,
CollisionTraverser *traverserQueue,
CollisionHandlerQueue *colliHandlerQueue,
Filename charDir,
Filename charWalkDir,
Filename charStandDir,
std::string lodNodename,
std::string colliNodeName) {
LODNode *lod = new LODNode(lodNodename);
NodePath lodNodePath(lod);
lodNodePath.reparent_to(player->getWindow()->get_render());
lod->add_switch(50, 0);
// load character and place on the grounds
NodePath character = player->getWindow()->load_model(player->getPanda()->get_models(), charDir);
character.reparent_to(lodNodePath);
character.set_scale(0.203, 0.203, 0.203);
// add collision node to character
CollisionNode *collNode = new CollisionNode(colliNodeName);
collNode->add_solid(new CollisionSphere(0, 0, 0, 2.5));
NodePath fromObj = character.attach_new_node(collNode);
CollisionHandlerPusher *colliHandlerPusher = new CollisionHandlerPusher();
colliHandlerPusher->add_collider(fromObj, character);
traverser->add_collider(fromObj, colliHandlerPusher);
traverserQueue->add_collider(fromObj, colliHandlerQueue);
// Load the walk animation
player->getWindow()->load_model(character, charStandDir);
player->getWindow()->load_model(character, charWalkDir);
// bind animation
auto_bind(character.node(), animCollection);
stopMoving();
nodePath = character;
standAnimName = animCollection.get_anim_name(0);
walkAnimName = animCollection.get_anim_name(1);
// get animation names
//for(int i = 0; i < animCollection.get_num_anims(); i++)
// cout << animCollection.get_anim_name(i) << endl;
}
示例8: ItemState
/** Constructor for an item.
* \param type Type of the item.
* \param xyz Location of the item.
* \param normal The normal upon which the item is placed (so that it can
* be aligned properly with the ground).
* \param mesh The mesh to be used for this item.
* \param owner 'Owner' of this item, i.e. the kart that drops it. This is
* used to deactivate this item for the owner, i.e. avoid that a kart
* 'collects' its own bubble gum. NULL means no owner, and the item
* can be collected immediatley by any kart.
*/
Item::Item(ItemType type, const Vec3& xyz, const Vec3& normal,
scene::IMesh* mesh, scene::IMesh* lowres_mesh,
const AbstractKart *owner)
: ItemState(type, owner)
{
m_was_available_previously = true;
m_distance_2 = 1.2f;
initItem(type, xyz, normal);
m_graphical_type = getGrahpicalType();
LODNode* lodnode =
new LODNode("item", irr_driver->getSceneManager()->getRootSceneNode(),
irr_driver->getSceneManager());
scene::ISceneNode* meshnode =
irr_driver->addMesh(mesh, StringUtils::insertValues("item_%i", (int)type));
if (lowres_mesh != NULL)
{
lodnode->add(35, meshnode, true);
scene::ISceneNode* meshnode =
irr_driver->addMesh(lowres_mesh,
StringUtils::insertValues("item_lo_%i", (int)type));
lodnode->add(100, meshnode, true);
}
else
{
lodnode->add(100, meshnode, true);
}
m_node = lodnode;
setType(type);
handleNewMesh(getGrahpicalType());
#ifdef DEBUG
std::string debug_name("item: ");
debug_name += getType();
m_node->setName(debug_name.c_str());
#endif
m_node->setAutomaticCulling(scene::EAC_FRUSTUM_BOX);
m_node->setPosition(xyz.toIrrVector());
Vec3 hpr;
hpr.setHPR(getOriginalRotation());
m_node->setRotation(hpr.toIrrHPR());
m_node->grab();
} // Item(type, xyz, normal, mesh, lowres_mesh)
示例9: visit
void visit( const LODNode& lodNode, VisitState& state )
{
const Boxf& worldBox = lodNode.getWorldBox();
if( !_frustum.isInFrustum( worldBox ) || _clipPlanes.isClipped( worldBox ))
{
state.setVisitChild( false );
return;
}
Vector3f vmin, vmax;
const Plane& nearPlane = _frustum.getNearPlane();
worldBox.computeNearFar( nearPlane, vmin, vmax );
Vector4f hVmin = vmin;
hVmin[ 3 ] = 1.0f;
Vector4f hVmax = vmax;
hVmax[ 3 ] = 1.0f;
// The bounding box intersects the plane
if( _frustum.getNearPlane().dot( hVmin ) < 0 ||
_frustum.getNearPlane().dot( hVmax ) < 0 )
{
// Where eye direction intersects with near plane
vmin = _frustum.getEyePos() - _frustum.getViewDir() * _frustum.nearPlane();
}
const Vector3f& voxelBox = lodNode.getVoxelBox().getSize();
const Vector3f& worldSpacePerVoxel = worldBox.getSize() / voxelBox;
bool lodVisible = isLODVisible( vmin, worldSpacePerVoxel.find_min( ));
const VolumeInformation& volInfo = _dataSource.getVolumeInfo();
const uint32_t depth = volInfo.rootNode.getDepth();
lodVisible = ( lodVisible && lodNode.getRefLevel() >= _minLOD )
|| ( lodNode.getRefLevel() == _maxLOD )
|| ( lodNode.getRefLevel() == depth - 1 );
if( lodVisible )
_visibles.push_back( lodNode.getNodeId( ));
state.setVisitChild( !lodVisible );
}
示例10: rotation
/** Resets the kart model. It stops animation from being played and resets
* the wheels to the correct position (i.e. no suspension).
*/
void KartModel::reset()
{
for (unsigned int i = 0; i < 4; i++)
{
if (m_wheel_node[i])
{
core::vector3df rotation(btScalar(rand() % 360), 0, 0);
m_wheel_node[i]->setRotation(rotation);
}
}
update(0.0f, 0.0f, 0.0f, 0.0f, 0.0f);
// Stop any animations currently being played.
setAnimation(KartModel::AF_DEFAULT);
// Don't force any LOD. Non-animated karts are not LOD nodes.
LODNode *lod = dynamic_cast<LODNode*>(m_kart->getNode());
if (lod)
lod->forceLevelOfDetail(-1);
} // reset
示例11: printf
LODNode* SceneLoader::LoadLODNode(QDomElement element)
{
if (element.nodeName() != QString ("node") ||
QString::compare(element.attribute("type"), "lod", Qt::CaseInsensitive) != 0)
{
printf ("ceXMLDataLoader::LoadLODNode: Illegal data format: '%s' != 'group'\n", element.attribute("type").toStdString().c_str()); fflush (stdout);
}
LODNode* lod = new LODNode ();
QString name = element.attribute("name");
if (!name.isNull())
{
lod->SetName(name.toStdString());
}
for (QDomElement groupElement = element.firstChildElement();
!groupElement.isNull();
groupElement = groupElement.nextSiblingElement())
{
ceNode* node = LoadNode (groupElement);
if (node)
{
lod->Get().Add(node);
}
}
lod->GetSolver()->SetNum(lod->Get().GetNumberOfLevels());
lod->UpdateBoundingBox();
return lod;
}
示例12: visit
bool visit(const LODNode& lodNode)
{
const Boxf& worldBox = lodNode.getWorldBox();
if (!_frustum.isInFrustum(worldBox) || _clipPlanes.isOutside(worldBox))
return false;
Vector3f vmin, vmax;
const Plane& nearPlane = _frustum.getNearPlane();
worldBox.computeNearFar(nearPlane, vmin, vmax);
Vector4f hVmin = vmin;
hVmin[3] = 1.0f;
Vector4f hVmax = vmax;
hVmax[3] = 1.0f;
// The bounding box intersects the plane
if (_frustum.getNearPlane().dot(hVmin) < 0 ||
_frustum.getNearPlane().dot(hVmax) < 0)
{
// Where eye direction intersects with near plane
vmin = _frustum.getEyePos() -
_frustum.getViewDir() * _frustum.nearPlane();
}
const Vector3f& voxelBox = lodNode.getVoxelBox().getSize();
const Vector3f& worldSpacePerVoxel = worldBox.getSize() / voxelBox;
const auto level = lodNode.getRefLevel();
bool lodVisible = isLODVisible(vmin, worldSpacePerVoxel.find_min()) &&
level >= _minLOD;
if (level == _maxLOD)
lodVisible = true;
if (lodVisible)
_visibles.push_back(lodNode.getNodeId());
return !lodVisible;
}
示例13: reset
// ----------------------------------------------------------------------------
void TrackObjectPresentationLOD::reset()
{
LODNode* ln = dynamic_cast<LODNode*>(m_node);
if (ln)
{
for (scene::ISceneNode* node : ln->getAllNodes())
{
scene::IAnimatedMeshSceneNode* a_node =
dynamic_cast<scene::IAnimatedMeshSceneNode*>(node);
if (a_node)
{
a_node->setLoopMode(true);
a_node->setAnimationEndCallback(NULL);
RandomGenerator rg;
int animation_set = 0;
if (a_node->getAnimationSetNum() > 0)
animation_set = rg.get(a_node->getAnimationSetNum());
a_node->useAnimationSet(animation_set);
}
}
}
} // reset
示例14: setEnabled
//.........这里部分代码省略.........
{
colorized = m;
break;
}
}
if (colorized != NULL)
{
break;
}
}
}
}
// If at least one material is colorizable, add RenderInfo for it
if (colorized != NULL)
{
const float hue = colorized->getRandomHue();
if (hue > 0.0f)
{
m_render_info = std::make_shared<RenderInfo>(hue);
}
}
}
#endif
scene::ISceneNode *glownode = NULL;
bool is_movable = false;
if (lod_instance)
{
m_type = "lod";
TrackObjectPresentationLOD* lod_node =
new TrackObjectPresentationLOD(xml_node, parent, model_def_loader, m_render_info);
m_presentation = lod_node;
LODNode* node = (LODNode*)lod_node->getNode();
if (type == "movable" && parent != NULL)
{
// HACK: unparent movables from their parent library object if any,
// because bullet provides absolute transforms, not transforms relative
// to the parent object
node->updateAbsolutePosition();
core::matrix4 absTransform = node->getAbsoluteTransformation();
node->setParent(irr_driver->getSceneManager()->getRootSceneNode());
node->setPosition(absTransform.getTranslation());
node->setRotation(absTransform.getRotationDegrees());
node->setScale(absTransform.getScale());
}
glownode = node->getAllNodes()[0];
}
else
{
m_type = "mesh";
m_presentation = new TrackObjectPresentationMesh(xml_node,
m_enabled,
parent,
m_render_info);
scene::ISceneNode* node = ((TrackObjectPresentationMesh *)m_presentation)->getNode();
if (type == "movable" && parent != NULL)
{
// HACK: unparent movables from their parent library object if any,
// because bullet provides absolute transforms, not transforms relative
// to the parent object
node->updateAbsolutePosition();
core::matrix4 absTransform = node->getAbsoluteTransformation();
node->setParent(irr_driver->getSceneManager()->getRootSceneNode());
node->setPosition(absTransform.getTranslation());
示例15: setKarts
void GrandPrixWin::setKarts(const std::string idents_arg[3])
{
TrackObjectManager* tobjman = Track::getCurrentTrack()->getTrackObjectManager();
// reorder in "podium order" (i.e. second player to the left, first player
// in the middle, last at the right)
std::string idents[3];
idents[0] = idents_arg[1];
idents[1] = idents_arg[0];
idents[2] = idents_arg[2];
for (int i = 0; i < 3; i++)
{
const KartProperties* kp = kart_properties_manager->getKart(idents[i]);
if (kp == NULL) continue;
KartModel* kart_model = kp->getKartModelCopy();
m_all_kart_models.push_back(kart_model);
scene::ISceneNode* kart_main_node = kart_model->attachModel(true, false);
LODNode* lnode = dynamic_cast<LODNode*>(kart_main_node);
if (lnode)
{
// Lod node has to be animated
auto* a_node = static_cast<scene::IAnimatedMeshSceneNode*>
(lnode->getAllNodes()[0]);
const unsigned start_frame =
kart_model->getFrame(KartModel::AF_WIN_LOOP_START) > -1 ?
kart_model->getFrame(KartModel::AF_WIN_LOOP_START) :
kart_model->getFrame(KartModel::AF_WIN_START) > -1 ?
kart_model->getFrame(KartModel::AF_WIN_START) :
kart_model->getFrame(KartModel::AF_STRAIGHT);
const unsigned end_frame =
kart_model->getFrame(KartModel::AF_WIN_END) > -1 ?
kart_model->getFrame(KartModel::AF_WIN_END) :
kart_model->getFrame(KartModel::AF_STRAIGHT);
a_node->setLoopMode(true);
a_node->setFrameLoop(start_frame, end_frame);
}
m_kart_x[i] = KARTS_INITIAL_X[i];
m_kart_y[i] = KARTS_INITIAL_Y[i];
m_kart_z[i] = KARTS_INITIAL_Z[i];
m_kart_rotation[i] = KARTS_AND_PODIUMS_INITIAL_ROTATION[i];
core::vector3df kart_pos(m_kart_x[i], m_kart_y[i], m_kart_z[i]);
core::vector3df kart_rot(0, 0, 0);
core::vector3df kart_scale(1.0f, 1.0f, 1.0f);
//FIXME: it's not ideal that both the track object and the presentation
// know the initial coordinates of the object
TrackObjectPresentationSceneNode* presentation =
new TrackObjectPresentationSceneNode(kart_pos, kart_rot, kart_scale,
kart_main_node);
TrackObject* tobj = new TrackObject(kart_pos, kart_rot, kart_scale,
"ghost", presentation, false /* isDynamic */, NULL /* physics settings */);
tobjman->insertObject(tobj);
m_kart_node[i] = tobj;
}
TrackObject* currObj;
PtrVector<TrackObject>& objects = tobjman->getObjects();
for_in(currObj, objects)
{
TrackObjectPresentationMesh* meshPresentation = currObj->getPresentation<TrackObjectPresentationMesh>();
if (meshPresentation != NULL)
{
if (meshPresentation->getModelFile() == "gpwin_podium1.spm")
m_podium_steps[0] = currObj;
else if (meshPresentation->getModelFile() == "gpwin_podium2.spm")
m_podium_steps[1] = currObj;
else if (meshPresentation->getModelFile() == "gpwin_podium3.spm")
m_podium_steps[2] = currObj;
}
}