本文整理汇总了C++中WorldObject::childsBegin方法的典型用法代码示例。如果您正苦于以下问题:C++ WorldObject::childsBegin方法的具体用法?C++ WorldObject::childsBegin怎么用?C++ WorldObject::childsBegin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WorldObject
的用法示例。
在下文中一共展示了WorldObject::childsBegin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: applyLights
/**
Walk recursively through a node and switch on all lights.
\param node World object to search for lights
*/
void GLRenderInstance::applyLights(WorldObject& node)
{
double M[16];
int idx=0;
WorldObject::ChildIterator it;
for(it=node.childsBegin(); it!=node.childsEnd(); it++)
{
glPushMatrix();
// Set the local transformation
it->second->localTransform().toList(M);
glMultMatrixd(M);
// Check if the object is a light source...
LightSource* lgt = dynamic_cast<LightSource*>(it->second.get());
if (lgt!=0)
{
// Is it a point light?
GLPointLight* pntlgt = dynamic_cast<GLPointLight*>(lgt);
if (pntlgt!=0)
{
if (pntlgt->enabled.getValue())
{
pntlgt->applyGL(idx);
glEnable(GL_LIGHT0+idx);
idx++;
}
}
// Is it a spot light?
GLSpotLight* spotlgt = dynamic_cast<GLSpotLight*>(lgt);
if (spotlgt!=0)
{
if (spotlgt->enabled.getValue())
{
spotlgt->applyGL(idx);
glEnable(GL_LIGHT0+idx);
idx++;
}
}
// Is it a distant light?
GLDistantLight* dstlgt = dynamic_cast<GLDistantLight*>(lgt);
if (dstlgt!=0)
{
if (dstlgt->enabled.getValue())
{
dstlgt->applyGL(idx);
glEnable(GL_LIGHT0+idx);
idx++;
}
}
}
// Search the children for lights
applyLights(*(it->second));
glPopMatrix();
}
}
示例2: drawNode
/**
Draw a tree.
\param node Node
\param draw_blends If true, only objects that use blending are drawn. Otherwise objects with
blending are not drawn.
\return True if the tree contained one or more objects that use blending
*/
bool GLRenderInstance::drawNode(WorldObject& node, bool draw_blends)
{
double M[16];
BoundingBox bb;
vec3d bmin, bmax, t, d;
bool render_flag = true;
bool res = false;
WorldObject::ChildIterator it;
for(it=node.childsBegin(); it!=node.childsEnd(); it++)
{
glPushMatrix();
// Set the local transformation
it->second->localTransform().toList(M);
glMultMatrixd(M);
// Draw the geom (if visible)
boost::shared_ptr<GeomObject> geom = it->second->getGeom();
if (geom.get()!=0 && (it->second->visible.getValue()))
{
// Render by default if draw_blends is false
render_flag = !draw_blends;
// Set material
boost::shared_ptr<Material> mat = it->second->getMaterial();
Material* bmat = dynamic_cast<Material*>(mat.get());
// Check if the object should be postponed because blending is used...
if (bmat!=0)
{
if (bmat->usesBlending())
{
res = true;
render_flag = draw_blends;
}
}
if (render_flag)
{
// Set material
glPushAttrib(GL_LIGHTING_BIT | GL_TEXTURE_BIT);
if (bmat!=0)
{
bmat->applyGL();
}
if (draw_solid)
{
clearGLError();
geom->drawGL();
}
// Draw bounding box
if (draw_bboxes)
{
bb = geom->boundingBox();
if (!bb.isEmpty())
{
glDisable(GL_LIGHTING);
bb.getBounds(bmin, bmax);
t = 0.5*(bmax+bmin);
d = bmax-bmin;
glPushMatrix();
glTranslated(t.x, t.y, t.z);
drawWireCube(d.x, d.y, d.z);
glPopMatrix();
glEnable(GL_LIGHTING);
}
}
glPopAttrib(); // restore material
}
}
// Draw the children
res |= drawNode(*(it->second), draw_blends);
glPopMatrix();
}
return res;
}