本文整理汇总了C++中NiNodeRef::ClearChildren方法的典型用法代码示例。如果您正苦于以下问题:C++ NiNodeRef::ClearChildren方法的具体用法?C++ NiNodeRef::ClearChildren怎么用?C++ NiNodeRef::ClearChildren使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NiNodeRef
的用法示例。
在下文中一共展示了NiNodeRef::ClearChildren方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
/*---------------------------------------------------------------------------*/
NiNodeRef NifPrepareUtility::parse4Blender(NiNodeRef pNode)
{
vector<NiAVObjectRef> childList(pNode->GetChildren());
list<NiExtraDataRef> extraList(pNode->GetExtraData());
// parse extra data for BSInvMarker
for (auto pIter(extraList.begin()), pEnd(extraList.end()); pIter != pEnd; pIter++)
{
if (_remBSInvMarker && (DynamicCast<BSInvMarker>(*pIter) != NULL))
{
pNode->RemoveExtraData(*pIter);
}
}
// unlink children
pNode->ClearChildren();
// iterate over children
for (auto pIter(childList.begin()), pEnd(childList.end()); pIter != pEnd; pIter++)
{
// NiTriShape => remove BSLightingShaderProperty
if (DynamicCast<NiTriShape>(*pIter) != NULL)
{
if (_remBSProperties)
{
NiTriShapeRef pShape (DynamicCast<NiTriShape>(*pIter));
// remove properties (Bethesda uses max. 2)
pShape->SetBSProperty(0, NULL);
pShape->SetBSProperty(1, NULL);
}
// add shape to node
pNode->AddChild(*pIter);
}
// BSInvMarker => remove whole object
else if (_remBSInvMarker && (DynamicCast<BSInvMarker>(*pIter) != NULL))
{
// skip entry => do not add to final list
}
// NiNode (and derived classes?) => iterate subnodes
else if (DynamicCast<NiNode>(*pIter) != NULL)
{
pNode->AddChild(&(*parse4Blender(DynamicCast<NiNode>(*pIter))));
}
} // for (auto pIter(childList.begin()), pEnd(childList.end()); pIter != pEnd; pIter++)
return pNode;
}
示例2: convertNiNode
/*---------------------------------------------------------------------------*/
NiNodeRef NifConvertUtility::convertNiNode(NiNodeRef pSrcNode, NiTriShapeRef pTmplNode, NiNodeRef pRootNode, NiAlphaPropertyRef pTmplAlphaProp)
{
NiNodeRef pDstNode (pSrcNode);
vector<NiAVObjectRef> srcShapeList(pDstNode->GetChildren());
// find NiAlphaProperty and use as template in sub-nodes
if (DynamicCast<NiAlphaProperty>(pDstNode->GetPropertyByType(NiAlphaProperty::TYPE)) != NULL)
{
pTmplAlphaProp = DynamicCast<NiAlphaProperty>(pDstNode->GetPropertyByType(NiAlphaProperty::TYPE));
}
// unlink protperties -> not used in new format
pDstNode->ClearProperties();
// shift extra data to new version
pDstNode->ShiftExtraData(VER_20_2_0_7);
// unlink children
pDstNode->ClearChildren();
// iterate over source nodes and convert using template
for (vector<NiAVObjectRef>::iterator ppIter = srcShapeList.begin(); ppIter != srcShapeList.end(); ppIter++)
{
// NiTriShape
//Type t = (*ppIter)->GetType();
if (DynamicCast<NiTriShape>(*ppIter) != NULL)
{
pDstNode->AddChild(&(*convertNiTriShape(DynamicCast<NiTriShape>(*ppIter), pTmplNode, pTmplAlphaProp)));
}
// NiNode (and derived classes?)
else if (DynamicCast<NiNode>(*ppIter) != NULL)
{
pDstNode->AddChild(&(*convertNiNode(DynamicCast<NiNode>(*ppIter), pTmplNode, pRootNode, pTmplAlphaProp)));
}
}
return pDstNode;
}
示例3: convertShape
/*---------------------------------------------------------------------------*/
unsigned int NifConvertUtility::convertShape(string fileNameSrc, string fileNameDst, string fileNameTmpl)
{
NiNodeRef pRootInput (NULL);
NiNodeRef pRootOutput (NULL);
NiNodeRef pRootTemplate (NULL);
NiTriShapeRef pNiTriShapeTmpl(NULL);
vector<NiAVObjectRef> srcChildList;
bool fakedRoot (false);
// test on existing file names
if (fileNameSrc.empty()) return NCU_ERROR_MISSING_FILE_NAME;
if (fileNameDst.empty()) return NCU_ERROR_MISSING_FILE_NAME;
if (fileNameTmpl.empty()) return NCU_ERROR_MISSING_FILE_NAME;
// initialize user messages
_userMessages.clear();
logMessage(NCU_MSG_TYPE_INFO, "Source: " + (fileNameSrc.empty() ? "- none -" : fileNameSrc));
logMessage(NCU_MSG_TYPE_INFO, "Template: " + (fileNameTmpl.empty() ? "- none -" : fileNameTmpl));
logMessage(NCU_MSG_TYPE_INFO, "Destination: " + (fileNameDst.empty() ? "- none -" : fileNameDst));
logMessage(NCU_MSG_TYPE_INFO, "Texture: " + (_pathTexture.empty() ? "- none -" : _pathTexture));
// initialize used texture list
_usedTextures.clear();
_newTextures.clear();
// read input NIF
if ((pRootInput = getRootNodeFromNifFile(fileNameSrc, "source", fakedRoot)) == NULL)
{
logMessage(NCU_MSG_TYPE_ERROR, "Can't open '" + fileNameSrc + "' as input");
return NCU_ERROR_CANT_OPEN_INPUT;
}
// get template nif
pRootTemplate = DynamicCast<BSFadeNode>(ReadNifTree((const char*) fileNameTmpl.c_str()));
if (pRootTemplate == NULL)
{
logMessage(NCU_MSG_TYPE_ERROR, "Can't open '" + fileNameTmpl + "' as template");
return NCU_ERROR_CANT_OPEN_TEMPLATE;
}
// get shapes from template
// - shape root
pNiTriShapeTmpl = DynamicCast<NiTriShape>(pRootTemplate->GetChildren().at(0));
if (pNiTriShapeTmpl == NULL)
{
logMessage(NCU_MSG_TYPE_INFO, "Template has no NiTriShape.");
}
// template root is used as root of output
pRootOutput = pRootTemplate;
// get rid of unwanted subnodes
pRootOutput->ClearChildren(); // remove all children
pRootOutput->SetCollisionObject(NULL); // unlink collision object
// hold extra data and property nodes
// copy translation from input node
pRootOutput->SetLocalTransform(pRootInput->GetLocalTransform());
// copy name of root node
pRootOutput->SetName(pRootInput->GetName());
// get list of children from input node
srcChildList = pRootInput->GetChildren();
// unlink children 'cause moved to output
pRootInput->ClearChildren();
// iterate over source nodes and convert using template
for (vector<NiAVObjectRef>::iterator ppIter = srcChildList.begin(); ppIter != srcChildList.end(); ppIter++)
{
// NiTriShape
if (DynamicCast<NiTriShape>(*ppIter) != NULL)
{
pRootOutput->AddChild(&(*convertNiTriShape(DynamicCast<NiTriShape>(*ppIter), pNiTriShapeTmpl)));
}
// RootCollisionNode
else if (DynamicCast<RootCollisionNode>(*ppIter) != NULL)
{
// ignore node
}
// NiNode (and derived classes?)
else if (DynamicCast<NiNode>(*ppIter) != NULL)
{
pRootOutput->AddChild(&(*convertNiNode(DynamicCast<NiNode>(*ppIter), pNiTriShapeTmpl, pRootOutput)));
}
}
// write missing textures to log - as block
for (set<string>::iterator pIter(_newTextures.begin()); pIter != _newTextures.end(); ++pIter)
{
logMessage(NCU_MSG_TYPE_TEXTURE_MISS, *pIter);
}
// write modified nif file
WriteNifTree((const char*) fileNameDst.c_str(), pRootOutput, NifInfo(VER_20_2_0_7, 12, 83));
return NCU_OK;
}
示例4: convertShape
/*---------------------------------------------------------------------------*/
unsigned int NifConvertUtility::convertShape(string fileNameSrc, string fileNameDst, string fileNameTmpl)
{
cout << "Here3" << endl;
NiNodeRef pRootInput (NULL);
NiNodeRef pRootOutput (NULL);
NiNodeRef pRootTemplate (NULL);
NiTriShapeRef pNiTriShapeTmpl(NULL);
NiCollisionObjectRef pRootCollObject(NULL);
NifInfo nifInfo;
vector<NiAVObjectRef> srcChildList;
bool fakedRoot (false);
cout << "Here4" << endl;
// test on existing file names
if (fileNameSrc.empty()) return NCU_ERROR_MISSING_FILE_NAME;
if (fileNameDst.empty()) return NCU_ERROR_MISSING_FILE_NAME;
if (fileNameTmpl.empty()) return NCU_ERROR_MISSING_FILE_NAME;
cout << "Here5" << endl;
// initialize user messages
_userMessages.clear();
logMessage(NCU_MSG_TYPE_INFO, "Source: " + (fileNameSrc.empty() ? "- none -" : fileNameSrc));
logMessage(NCU_MSG_TYPE_INFO, "Template: " + (fileNameTmpl.empty() ? "- none -" : fileNameTmpl));
logMessage(NCU_MSG_TYPE_INFO, "Destination: " + (fileNameDst.empty() ? "- none -" : fileNameDst));
logMessage(NCU_MSG_TYPE_INFO, "Texture: " + (_pathTexture.empty() ? "- none -" : _pathTexture));
cout << "Here6" << endl;
// initialize used texture list
_usedTextures.clear();
_newTextures.clear();
cout << "Here7" << endl;
// read input NIF
if ((pRootInput = getRootNodeFromNifFile(fileNameSrc, "source", fakedRoot, &nifInfo)) == NULL)
{
logMessage(NCU_MSG_TYPE_ERROR, "Can't open '" + fileNameSrc + "' as input");
return NCU_ERROR_CANT_OPEN_INPUT;
}
cout << "Here8" << endl;
// get template nif
pRootTemplate = DynamicCast<BSFadeNode>(ReadNifTree((const char*) fileNameTmpl.c_str()));
if (pRootTemplate == NULL)
{
logMessage(NCU_MSG_TYPE_ERROR, "Can't open '" + fileNameTmpl + "' as template");
return NCU_ERROR_CANT_OPEN_TEMPLATE;
}
cout << "Here9" << endl;
// get shapes from template
// - shape root
pNiTriShapeTmpl = DynamicCast<NiTriShape>(pRootTemplate->GetChildren().at(0));
if (pNiTriShapeTmpl == NULL)
{
logMessage(NCU_MSG_TYPE_INFO, "Template has no NiTriShape.");
}
cout << "Here10" << endl;
// get data from input node
srcChildList = pRootInput->GetChildren();
pRootCollObject = pRootInput->GetCollisionObject();
cout << "Here11" << endl;
// template root is used as root of output
pRootOutput = pRootTemplate;
// move date from input to output
pRootInput ->SetCollisionObject(NULL);
pRootOutput->SetCollisionObject(pRootCollObject);
pRootOutput->SetLocalTransform(pRootInput->GetLocalTransform());
pRootOutput->SetName(pRootInput->GetName());
cout << "Here12" << endl;
// get rid of unwanted subnodes
pRootOutput->ClearChildren();
pRootInput->ClearChildren();
cout << "Here13" << endl;
// move children to output
for (auto pIter=srcChildList.begin(), pEnd=srcChildList.end(); pIter != pEnd; ++pIter)
{
pRootOutput->AddChild(*pIter);
}
cout << "Here14" << endl;
// iterate over source nodes and convert using template
root_bsafade = pRootOutput;
pRootOutput = convertNiNode(pRootOutput, pNiTriShapeTmpl, pRootOutput);
cout << "Here15" << endl;
// write missing textures to log - as block
for (auto pIter=_newTextures.begin(), pEnd=_newTextures.end(); pIter != pEnd; ++pIter)
{
logMessage(NCU_MSG_TYPE_TEXTURE_MISS, *pIter);
}
cout << "Here16" << endl;
// set version information
stringstream sStream;
cout << "Here17" << endl;
sStream << nifInfo.version << ';' << nifInfo.userVersion;
nifInfo.version = VER_20_2_0_7;
nifInfo.userVersion = 12;
nifInfo.userVersion2 = 83;
nifInfo.creator = "NifConvert";
nifInfo.exportInfo1 = MASTER_PRODUCT_VERSION_STR;
nifInfo.exportInfo2 = sStream.str();
cout << "Here18" << endl;
// write modified nif file
WriteNifTree((const char*) fileNameDst.c_str(), pRootOutput, nifInfo);
cout << "Here19" << endl;
return NCU_OK;
//.........这里部分代码省略.........
示例5: convertNiNode
NiNodeRef NifConvertUtility::convertNiNode(NiNodeRef pSrcNode, NiTriShapeRef pTmplNode, NiNodeRef pRootNode, NiAlphaPropertyRef pTmplAlphaProp)
{
NiNodeRef pDstNode (pSrcNode);
//pDstNode->SetName(pDstNode->GetName().replace(
string node_name_in = pDstNode->GetName();
string node_name_out = "";
for (int i = 0; i < node_name_in.length(); i++)
{
if (node_name_in[i] != '.' && node_name_in[i] != '_' && node_name_in[i] != ' ')
{
node_name_out = node_name_out + node_name_in[i];
}
}
pDstNode->SetName(node_name_out);
node_name_in = node_name_out;
if (node_name_in.compare("AttachLight") == 0)
{
Vector3 tr = pDstNode->GetLocalTranslation();
tr.z += 10.0f;
pDstNode->SetLocalTranslation(tr);
}
if (node_name_in.compare("ShadowBox") == 0)
{
cout << "Removing ShadowBox" << endl;
pDstNode->ClearChildren();
}
if (toLower(node_name_in).find("fireemit") != -1)
{
NiExtraDataRef ed = root_bsafade->GetExtraData().front();
NiIntegerExtraDataRef iref = DynamicCast<NiIntegerExtraData>(ed);
iref->SetData(147);
cout << "Adding TorchFlame Addon" << endl;
BSValueNodeRef candle_flame = new BSValueNode();
candle_flame->SetName("AddOnNode");
candle_flame->value = 46;
pDstNode->AddChild(DynamicCast<NiAVObject>(candle_flame));
}
else if (node_name_in.find("CandleFlame") != -1)
{
NiExtraDataRef ed = root_bsafade->GetExtraData().front();
NiIntegerExtraDataRef iref = DynamicCast<NiIntegerExtraData>(ed);
iref->SetData(147);
cout << "Adding CandleFlame Addon" << endl;
BSValueNodeRef candle_flame = new BSValueNode();
candle_flame->SetName("AddOnNode");
candle_flame->value = 49;
pDstNode->AddChild(DynamicCast<NiAVObject>(candle_flame));
}
vector<NiAVObjectRef> srcShapeList(pDstNode->GetChildren());
//if (!pDstNode->GetType().IsSameType(NiNode::TYPE) && !pDstNode->GetType().IsSameType(BSFadeNode::TYPE) && !pDstNode->GetType().IsSameType(NiTriShape::TYPE) && !pDstNode->GetType().IsSameType(NiTriStrips::TYPE))
{
}
// find NiAlphaProperty and use as template in sub-nodes
if (DynamicCast<NiAlphaProperty>(pDstNode->GetPropertyByType(NiAlphaProperty::TYPE)) != NULL)
{
pTmplAlphaProp = DynamicCast<NiAlphaProperty>(pDstNode->GetPropertyByType(NiAlphaProperty::TYPE));
}
// unlink protperties -> not used in new format
pDstNode->ClearProperties();
// shift extra data to new version
pDstNode->ShiftExtraData(VER_20_2_0_7);
// unlink children
pDstNode->ClearChildren();
pDstNode->ClearEffects();
pDstNode->ClearControllers();
if (!pDstNode->GetType().IsSameType(BSFadeNode::TYPE))
{
pDstNode->ClearExtraData();
}
// iterate over source nodes and convert using template
for (auto ppIter=srcShapeList.begin(), pEnd=srcShapeList.end(); ppIter != pEnd; ppIter++)
{
//DynamicCast<NiTriShape>(*ppIter) == NULL && DynamicCast<NiTriStrips>(*ppIter) == NULL ** DynamicCast<NiTriStrips>(*ppIter) != NULL
//.........这里部分代码省略.........