本文整理汇总了C++中NiNodeRef类的典型用法代码示例。如果您正苦于以下问题:C++ NiNodeRef类的具体用法?C++ NiNodeRef怎么用?C++ NiNodeRef使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NiNodeRef类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cleanTreeCollision
/*---------------------------------------------------------------------------*/
void NifCollisionUtility::cleanTreeCollision(NiNodeRef pNode)
{
vector<NiAVObjectRef> srcChildList(pNode->GetChildren()); // children of node
// remove collision object (new style [>= Oblivion])
pNode->SetCollisionObject(NULL);
// iterate over source nodes and remove possible old-style [Morrowind] collision node
for (auto ppIter=srcChildList.begin(), pEnd=srcChildList.end(); ppIter != pEnd; ppIter++)
{
// RootCollisionNode
if (DynamicCast<RootCollisionNode>(*ppIter) != NULL)
{
pNode->RemoveChild(*ppIter);
}
// NiNode
else if (DynamicCast<NiNode>(*ppIter) != NULL)
{
cleanTreeCollision(DynamicCast<NiNode>(*ppIter));
}
// other children
else
{
(*ppIter)->SetCollisionObject(NULL);
}
} // for (vector<NiAVObjectRef>::iterator ppIter = srcChildList.begin(); ....
}
示例2: strmatch
NiNodeRef Exporter::createNode(INode* maxNode, const string& name)
{
USES_CONVERSION;
bool ismatch = strmatch(T2A(maxNode->GetName()), name);
if (ismatch) {
NodeToNodeMap::iterator itr = mNodeMap.find(maxNode);
if (itr != mNodeMap.end())
return (*itr).second;
}
NiNodeRef node;
if (!findNode(name, node))
{
node = createNode();
BOOL noname = FALSE;
if (!maxNode->GetUserPropBool(NP_NONAME, noname) || !noname)
node->SetName(name);
}
if (wildmatch("noname*", name))
{
maxNode->SetUserPropBool(NP_NONAME, TRUE);
}
mNodeMap[maxNode] = node;
return node;
}
示例3: NiSkinInstance
NiSkinInstance::NiSkinInstance( NiNode * skeleton_root, vector< Ref<NiNode> > bone_nodes ) {
//Call normal constructor
NiSkinInstance();
//Ensure that all bones are below the skeleton root node on the scene graph
for ( unsigned int i = 0; i < bone_nodes.size(); ++i ) {
bool is_decended = false;
NiNodeRef node = bone_nodes[i];
while ( node != NULL ) {
if ( node == skeleton_root ) {
is_decended = true;
break;
}
node = node->GetParent();
}
if ( is_decended == false ) {
throw runtime_error( "All bones must be lower than the skeleton root in the scene graph." );
}
}
//Add the bones to the internal list
bones.resize( bone_nodes.size() );
for ( unsigned int i = 0; i < bone_nodes.size(); ++i ) {
bones[i] = bone_nodes[i];
}
//Flag any bones that are part of this skin instance
for ( unsigned int i = 0; i < bones.size(); ++i ) {
bones[i]->SetSkinFlag(true);
}
//Store skeleton root and inform it of this attachment
skeletonRoot = skeleton_root;
skeletonRoot->AddSkin( this );
}
示例4: ImportMesh
bool NifImporter::ImportMeshes(NiNodeRef node)
{
bool ok = true;
try
{
#if 1
vector<NiTriShapeRef> trinodes = DynamicCast<NiTriShape>(node->GetChildren());
for (vector<NiTriShapeRef>::iterator itr = trinodes.begin(), end = trinodes.end(); itr != end; ++itr){
ok |= ImportMesh(*itr);
}
vector<NiTriStripsRef> tristrips = DynamicCast<NiTriStrips>(node->GetChildren());
for (vector<NiTriStripsRef>::iterator itr = tristrips.begin(), end = tristrips.end(); itr != end; ++itr){
ok |= ImportMesh(*itr);
}
#else
// Only do multiples on object that have same name and use XXX:# notation
vector<NiTriBasedGeomRef> trigeom = DynamicCast<NiTriBasedGeom>(node->GetChildren());
ok |= ImportMultipleGeometry(node, trigeom);
#endif
vector<NiNodeRef> nodes = DynamicCast<NiNode>(node->GetChildren());
for (vector<NiNodeRef>::iterator itr = nodes.begin(), end = nodes.end(); itr != end; ++itr){
ok |= ImportMeshes(*itr);
}
}
catch( exception & e )
{
e=e;
ok = false;
}
catch( ... )
{
ok = false;
}
return ok;
}
示例5: createNode
NiNodeRef Exporter::createNode()
{
NiNodeRef node = CreateNiObject<NiNode>();
if (IsFallout3() || IsSkyrim()) {
node->SetFlags(14);
}
return node;
}
示例6: sortNodes
void Exporter::sortNodes(NiNodeRef node)
{
node->SortChildren(SortNodeEquivalence());
vector<NiNodeRef> children = DynamicCast<NiNode>(node->GetChildren());
for (vector<NiNodeRef>::iterator itr = children.begin(); itr != children.end(); ++itr)
sortNodes(*itr);
}
示例7: GoToSkeletonBindPosition
void GoToSkeletonBindPosition(vector<NiNodeRef>& blocks)
{
//Send all skeleton roots to bind position
for (unsigned int i = 0; i < blocks.size(); ++i) {
NiNodeRef node = blocks[i];
if ( node != NULL && node->IsSkeletonRoot() ) {
node->GoToSkeletonBindPosition();
}
}
}
示例8: return
NiNodeRef Exporter::getNode(const string& name)
{
NodeMap::iterator itr = mNameMap.find(name);
if (itr != mNameMap.end())
return (*itr).second;
NiNodeRef node = CreateNiObject<NiNode>();
if ( IsFallout3() || IsSkyrim() ) {
node->SetFlags( 14 );
}
node->SetName(name);
mNameMap[name] = node;
return node;
}
示例9: dumpNif
/**
* @brief writes the given nif to the given file.
*/
void dumpNif(const std::string& n, CellMeshList& l){
using namespace Niflib;
NiNodeRef node = new NiNode;
for ( std::list<NiAVObjectRef>::iterator iter = l.begin(); l.end() != iter; ++iter)
if ( *iter )
node->AddChild(*iter);
NiObjectRef obj = DynamicCast<NiObject>( node );
unsigned ver = 67108866;
WriteNifTree(n, obj, NifInfo(ver));
}
示例10: getGeometryFromNode
/*---------------------------------------------------------------------------*/
unsigned int NifCollisionUtility::getGeometryFromNode(NiNodeRef pNode, vector<hkGeometry>& geometryMap, vector<hkGeometry>& geometryMapColl, vector<Matrix44>& transformAry)
{
bhkCollisionObjectRef pCollObject(DynamicCast<bhkCollisionObject>(pNode->GetCollisionObject()));
vector<NiAVObjectRef> childList (pNode->GetChildren());
// add own translation to list
transformAry.push_back(pNode->GetLocalTransform());
// get geometry from collision object
if (pCollObject != NULL)
{
// search for embedded shape
bhkRigidBodyRef pRBody(DynamicCast<bhkRigidBody>(pCollObject->GetBody()));
if (pRBody != NULL)
{
getGeometryFromCollShape(pRBody->GetShape(), geometryMapColl, transformAry);
}
} // if (pCollObject != NULL)
// iterate over children
for (vector<NiAVObjectRef>::iterator ppIter = childList.begin(); ppIter != childList.end(); ppIter++)
{
// NiTriShape
if (DynamicCast<NiTriShape>(*ppIter) != NULL)
{
getGeometryFromTriShape(DynamicCast<NiTriShape>(*ppIter), geometryMap, transformAry);
}
// NiTriStrips
else if (DynamicCast<NiTriStrips>(*ppIter) != NULL)
{
getGeometryFromTriStrips(DynamicCast<NiTriStrips>(*ppIter), geometryMap, transformAry);
}
// RootCollisionNode
else if (DynamicCast<RootCollisionNode>(*ppIter) != NULL)
{
getGeometryFromNode(&(*DynamicCast<RootCollisionNode>(*ppIter)), geometryMapColl, geometryMapColl, transformAry);
}
// NiNode (and derived classes?)
else if (DynamicCast<NiNode>(*ppIter) != NULL)
{
getGeometryFromNode(DynamicCast<NiNode>(*ppIter), geometryMap, geometryMapColl, transformAry);
}
} // for (vector<NiAVObjectRef>::iterator ppIter = childList.begin(); ppIter != childList.end(); ppIter++)
// remove own translation from list
transformAry.pop_back();
return geometryMap.size();
}
示例11: IsBiped
bool NifImporter::IsBiped()
{
if (HasSkeleton()){
NiNodeRef rootNode = root;
if (rootNode){
list<NiExtraDataRef> extraData = rootNode->GetExtraData();
if (!extraData.empty()) {
if ( BSXFlagsRef flags = SelectFirstObjectOfType<BSXFlags>(extraData) ) {
return (flags->GetData() & 0x4);
}
}
}
}
return false;
}
示例12: CalcScale
static float CalcScale(INode *bone, NiNodeRef node, vector<NiNodeRef>& children)
{
int n = bone->NumberOfChildren();
if (n > 0)
{
float len1 = 0.0f;
float len2 = 0.0f;
Matrix3 m = bone->GetNodeTM(0);
Matrix3 m2 = TOMATRIX3(node->GetWorldTransform());
for (int i = 0; i<n; i++)
{
INode *child = bone->GetChildNode(i);
LPCTSTR name = child->GetName();
if (HasBipedPosDOF(name))
continue;
Matrix3 cm = child->GetObjectTM(0);
len1 += Length(m.GetTrans()-cm.GetTrans());
if (NiNodeRef child2 = FindNodeByName(children, string(child->GetName()))){
Matrix3 cm2 = TOMATRIX3(child2->GetWorldTransform());
len2 += Length(m2.GetTrans()-cm2.GetTrans());
}
}
return (len2 != 0.0f && len1 != 0.0f) ? (len2/len1) : 1.0f;
}
return 1.0f;
}
示例13: setName
void Exporter::setName(NiNodeRef node, const string& name)
{
USES_CONVERSION;
tstring tname = A2TString(name);
node->SetName(name);
mNameMap[tname] = node;
}
示例14: exportUPB
bool Exporter::exportUPB(NiNodeRef &root, INode *node)
{
bool ok = false;
if (!mUserPropBuffer)
return ok;
// Write the actual UPB sans any np_ prefixed strings
TSTR upb;
node->GetUserPropBuffer(upb);
if (!upb.isNull())
{
string line;
istringstream istr(string(upb), ios_base::out);
ostringstream ostr;
while (!istr.eof()) {
std::getline(istr, line);
if (!line.empty() && 0 != line.compare(0, 3, "np_"))
ostr << line << endl;
}
if (!ostr.str().empty())
{
NiStringExtraDataRef strings = CreateNiObject<NiStringExtraData>();
strings->SetName("UPB");
strings->SetData(ostr.str());
root->AddExtraData(DynamicCast<NiExtraData>(strings));
ok = true;
}
}
return ok;
}
示例15: ApplyAllSkinOffsets
void Exporter::ApplyAllSkinOffsets( NiAVObjectRef & root ) {
NiGeometryRef niGeom = DynamicCast<NiGeometry>(root);
if ( niGeom != NULL && niGeom->IsSkin() == true ) {
niGeom->ApplySkinOffset();
}
NiNodeRef niNode = DynamicCast<NiNode>(root);
if ( niNode != NULL ) {
//Call this function on all children
vector<NiAVObjectRef> children = niNode->GetChildren();
for ( unsigned i = 0; i < children.size(); ++i ) {
ApplyAllSkinOffsets( children[i] );
}
}
}