本文整理汇总了C++中osg::Node::getDescriptions方法的典型用法代码示例。如果您正苦于以下问题:C++ Node::getDescriptions方法的具体用法?C++ Node::getDescriptions怎么用?C++ Node::getDescriptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osg::Node
的用法示例。
在下文中一共展示了Node::getDescriptions方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: writeNodeExtra
// Write non-standard node data as extra of type "Node" with "OpenSceneGraph" technique
void daeWriter::writeNodeExtra(osg::Node &node)
{
unsigned int numDesc = node.getDescriptions().size();
// Only create extra if descriptions are filled in
if (writeExtras && (numDesc > 0))
{
// Adds the following to a node
//<extra type="Node">
// <technique profile="OpenSceneGraph">
// <Descriptions>
// <Description>Some info</Description>
// </Descriptions>
// </technique>
//</extra>
domExtra *extra = daeSafeCast<domExtra>(currentNode->add( COLLADA_ELEMENT_EXTRA ));
extra->setType("Node");
domTechnique *teq = daeSafeCast<domTechnique>(extra->add( COLLADA_ELEMENT_TECHNIQUE ) );
teq->setProfile( "OpenSceneGraph" );
domAny *descriptions = (domAny*)teq->add( "Descriptions" );
for (unsigned int currDesc = 0; currDesc < numDesc; currDesc++)
{
std::string value = node.getDescription(currDesc);
if (!value.empty())
{
domAny *description = (domAny*)descriptions->add( "Description" );
description->setValue(value.c_str());
}
}
}
}
示例2: createAssetTag
// Overloaded version of createAssetTag that provides the ability to specify
// user defined values for child elements within asset tags
void daeWriter::createAssetTag(const osg::Node &node)
{
domAsset *asset = daeSafeCast<domAsset>(dom->add(COLLADA_ELEMENT_ASSET));
domAsset::domCreated *c = daeSafeCast<domAsset::domCreated>(asset->add("created"));
domAsset::domModified *m = daeSafeCast<domAsset::domModified>(asset->add("modified"));
domAsset::domUnit *u = daeSafeCast<domAsset::domUnit>(asset->add("unit"));
domAsset::domUp_axis *up_axis = daeSafeCast<domAsset::domUp_axis>(asset->add("up_axis"));
domAsset::domContributor *contributor = daeSafeCast<domAsset::domContributor>(asset->add("contributor"));
// set date and time
// Generate the date like this
// "YYYY-mm-ddTHH:MM:SSZ" ISO 8601 Date Time format
const size_t bufSize = 1024;
static char dateStamp[bufSize];
time_t rawTime = time(NULL);
struct tm *timeInfo = localtime(&rawTime);
strftime(dateStamp, sizeof(dateStamp), "%Y-%m-%dT%H:%M:%SZ", timeInfo);
// set up fallback defaults
c->setValue(dateStamp);
m->setValue(dateStamp);
u->setName("meter"); // NOTE: SketchUp incorrectly sets this to "meters" but it does not really matter.
// Also note that since the default is: <unit meter="1.0" name="meter"/> this is equivalent to <unit/>
u->setMeter(1.0); // this is the important units setting as it tells consuming apps how to convert to meters.
up_axis->setValue(UPAXISTYPE_Z_UP);
// get description info as name value pairs
if (node.getDescriptions().size() % 2 == 0)
{
for (osg::Node::DescriptionList::const_iterator ditr = node.getDescriptions().begin();
ditr != node.getDescriptions().end();
++ditr)
{
std::string attrName(*ditr); ++ditr;
std::string attrValue(*ditr);
if (attrName == "collada_created" && !attrValue.empty())
{
c->setValue(attrValue.c_str());
}
else if (attrName == "collada_modified" && !attrValue.empty())
{
m->setValue(attrValue.c_str());
}
else if (attrName == "collada_keywords" && !attrValue.empty())
{
domAsset::domKeywords *keywords = daeSafeCast<domAsset::domKeywords>(asset->add("keywords"));
keywords->setValue(attrValue.c_str());
}
else if (attrName == "collada_revision" && !attrValue.empty())
{
domAsset::domRevision *revision = daeSafeCast<domAsset::domRevision>(asset->add("revision"));
revision->setValue(attrValue.c_str());
}
else if (attrName == "collada_subject" && !attrValue.empty())
{
domAsset::domSubject *subject = daeSafeCast<domAsset::domSubject>(asset->add("subject"));
subject->setValue(attrValue.c_str());
}
else if (attrName == "collada_title" && !attrValue.empty())
{
domAsset::domTitle *title = daeSafeCast<domAsset::domTitle>(asset->add("title"));
title->setValue(attrValue.c_str());
}
else if (attrName == "collada_up_axis" && !attrValue.empty())
{
if (attrValue == "X_UP")
{
up_axis->setValue(UPAXISTYPE_X_UP);
}
else if (attrValue == "Y_UP")
{
up_axis->setValue(UPAXISTYPE_Y_UP);
}
else
{
up_axis->setValue(UPAXISTYPE_Z_UP); // default
}
}
else if (attrName == "collada_unit_name" && !attrValue.empty())
{
u->setName(attrValue.c_str());
}
else if (attrName == "collada_unit_meter_length" && !attrValue.empty())
{
double fValFromStr(1.0);
try
{
std::istringstream sConversion(attrValue);
sConversion >> fValFromStr;
u->setMeter((domFloat)fValFromStr);
}
catch (...)
//.........这里部分代码省略.........