当前位置: 首页>>代码示例>>C++>>正文


C++ NiNodeRef::GetChildren方法代码示例

本文整理汇总了C++中NiNodeRef::GetChildren方法的典型用法代码示例。如果您正苦于以下问题:C++ NiNodeRef::GetChildren方法的具体用法?C++ NiNodeRef::GetChildren怎么用?C++ NiNodeRef::GetChildren使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NiNodeRef的用法示例。


在下文中一共展示了NiNodeRef::GetChildren方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ImportMeshes

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;
}
开发者ID:blabbatheorange,项目名称:Nif-Plugin,代码行数:35,代码来源:ImportMeshAndSkin.cpp

示例2: 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(); ....
}
开发者ID:Hashmi1,项目名称:NifConvert,代码行数:28,代码来源:NifCollisionUtility.cpp

示例3: removeUnreferencedBones

bool Exporter::removeUnreferencedBones(NiNodeRef node)
{
   NiNodeRef parent = node->GetParent();
   bool remove = (NULL != parent) && !node->IsSkinInfluence();
   Matrix44 ntm = node->GetLocalTransform();
   vector<NiAVObjectRef> children = node->GetChildren();
   for (vector<NiAVObjectRef>::iterator itr = children.begin(); itr != children.end(); ++itr)
   {
      NiAVObjectRef& child = (*itr);
      bool childRemove = false;
      if (child->IsDerivedType(NiNode::TYPE))
      {
         childRemove = removeUnreferencedBones(StaticCast<NiNode>(child));
      }
      if (childRemove)
      {
         node->RemoveChild(child);
      }
      else if (remove) // Reparent abandoned nodes to root
      {
         Matrix44 tm = child->GetLocalTransform();
         child->SetLocalTransform( ntm * tm );
         node->RemoveChild(child);
         mNiRoot->AddChild(child);
      }
   }
   return remove;
}
开发者ID:Anchoys1,项目名称:max_nif_plugin,代码行数:28,代码来源:Util.cpp

示例4: 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);
}
开发者ID:Anchoys1,项目名称:max_nif_plugin,代码行数:8,代码来源:Util.cpp

示例5: BuildNodes

static void BuildNodes(NiNodeRef object, vector<NiNodeRef>& nodes)
{
   if (!object)
      return;
   nodes.push_back(object);
   vector<NiNodeRef> links = DynamicCast<NiNode>(object->GetChildren());
   for (vector<NiNodeRef>::iterator itr = links.begin(), end = links.end(); itr != end; ++itr)
      BuildNodes(*itr, nodes);
}
开发者ID:ElliotWood,项目名称:max_nif_plugin,代码行数:9,代码来源:NIFImport.cpp

示例6: 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();
}
开发者ID:Hashmi1,项目名称:NifConvert,代码行数:51,代码来源:NifCollisionUtility.cpp

示例7: 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;
}
开发者ID:Hashmi1,项目名称:NifConvert,代码行数:50,代码来源:NifPrepareUtility.cpp

示例8: 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] );
      }
   }
} 
开发者ID:Anchoys1,项目名称:max_nif_plugin,代码行数:16,代码来源:Util.cpp

示例9: 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;
}
开发者ID:Pranke,项目名称:skywindtools,代码行数:39,代码来源:NifConvertUtility.cpp

示例10: getGeometryFromNifFile

/*---------------------------------------------------------------------------*/
unsigned int NifCollisionUtility::getGeometryFromNifFile(string fileName, vector<hkGeometry>& geometryMap)
{
	NiNodeRef				pRootInput (NULL);
	bhkCollisionObjectRef	pCollObject(NULL);
	vector<NiAVObjectRef>	srcChildList;
	vector<Matrix44>		transformAry;
	vector<hkGeometry>		geometryMapColl;
	vector<hkGeometry>		geometryMapShape;
	bool					fakedRoot  (false);

	//  read input NIF
	if ((pRootInput = getRootNodeFromNifFile(fileName, "collSource", fakedRoot, true)) == NULL)
	{
		return NCU_ERROR_CANT_OPEN_INPUT;
	}

	//  get geometry from collision object
	pCollObject = DynamicCast<bhkCollisionObject>(pRootInput->GetCollisionObject());
	if (pCollObject != NULL)
	{
		//  search for embedded shape
		bhkRigidBodyRef		pRBody(DynamicCast<bhkRigidBody>(pCollObject->GetBody()));

		if (pRBody != NULL)
		{
			getGeometryFromCollShape(pRBody->GetShape(), geometryMapColl, transformAry);
		}
	}  //  if (pCollObject != NULL)

	//  get list of children from input node
	srcChildList = pRootInput->GetChildren();

	//  iterate over source nodes and get geometry
	for (vector<NiAVObjectRef>::iterator  ppIter = srcChildList.begin(); ppIter != srcChildList.end(); ppIter++)
	{
		//  NiTriShape
		if (DynamicCast<NiTriShape>(*ppIter) != NULL)
		{
			getGeometryFromTriShape(DynamicCast<NiTriShape>(*ppIter), geometryMapShape, transformAry);
		}
		//  NiTriStrips
		else if (DynamicCast<NiTriStrips>(*ppIter) != NULL)
		{
			getGeometryFromTriStrips(DynamicCast<NiTriStrips>(*ppIter), geometryMapShape, 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), geometryMapShape, geometryMapColl, transformAry);
		}
	}

	//  which geomertry should be used?
	if ((_cnHandling == NCU_CN_COLLISION) || (_cnHandling == NCU_CN_FALLBACK))
	{
		geometryMap.swap(geometryMapColl);
	}
	else if (_cnHandling == NCU_CN_SHAPES)
	{
		geometryMap.swap(geometryMapShape);
	}
	if ((_cnHandling == NCU_CN_FALLBACK) && (geometryMap.size() <= 0))
	{
		geometryMap.swap(geometryMapShape);
	}

	return geometryMap.size();
}
开发者ID:Hashmi1,项目名称:NifConvert,代码行数:74,代码来源:NifCollisionUtility.cpp

示例11: 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;
}
开发者ID:Pranke,项目名称:skywindtools,代码行数:100,代码来源:NifConvertUtility.cpp

示例12: 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;
//.........这里部分代码省略.........
开发者ID:Hashmi1,项目名称:NifConvert,代码行数:101,代码来源:NifConvertUtility.cpp

示例13: 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
//.........这里部分代码省略.........
开发者ID:Hashmi1,项目名称:NifConvert,代码行数:101,代码来源:NifConvertUtility.cpp

示例14: parseTreeCollision

/*---------------------------------------------------------------------------*/
bool NifCollisionUtility::parseTreeCollision(NiNodeRef pNode, string fileNameCollTmpl, vector<hkGeometry>& geometryMapColl)
{
	vector<NiAVObjectRef>	srcChildList (pNode->GetChildren());	//  get list of children from input node
	bool					haveCollision(false);

	//  check for own collision object
	if (DynamicCast<bhkCollisionObject>(pNode->GetCollisionObject()) != NULL)
	{
		bhkCollisionObjectRef	pCollObj(DynamicCast<bhkCollisionObject>(pNode->GetCollisionObject()));
		bhkRigidBodyRef			pRBody  (DynamicCast<bhkRigidBody>      (pCollObj->GetBody()));

		//  check on valid body
		if (pRBody != NULL)
		{
			array<7, unsigned short>	unknown7(pRBody->GetUnknown7Shorts());

			//  force SKYRIM values
			unknown7[3] = 0;
			unknown7[4] = 0;
			unknown7[5] = 1;
			unknown7[6] = 65535;
			pRBody->SetUnknown7Shorts(unknown7);
			pRBody->SetTranslation(pRBody->GetTranslation() * 0.1f);

			pRBody->SetShape(parseCollisionShape(fileNameCollTmpl, pRBody->GetShape(), pRBody));

		}  //  if (pRBody != NULL)

		haveCollision |= true;

	}  //  if (DynamicCast<bhkCollisionObject>(pNode->GetCollisionObject()) != NULL)

	//  iterate over source nodes and get geometry
	for (vector<NiAVObjectRef>::iterator  ppIter = srcChildList.begin(); ppIter != srcChildList.end(); ppIter++)
	{
		//  RootCollisionNode
		if (DynamicCast<RootCollisionNode>(*ppIter) != NULL)
		{
			NiNodeRef				pRootTemplate(DynamicCast<BSFadeNode>(ReadNifTree((const char*) fileNameCollTmpl.c_str())));
			vector<hkGeometry>		geometryMapCollLocal;
			vector<Matrix44>		transformAryLocal;

			//  get template
			if (pRootTemplate != NULL)
			{
				bhkCollisionObjectRef	pCollNodeTmpl(DynamicCast<bhkCollisionObject>(pRootTemplate->GetCollisionObject()));

				if (pCollNodeTmpl != NULL)
				{
					//  get collision data from sub-nodes
					getGeometryFromNode(&(*DynamicCast<RootCollisionNode>(*ppIter)), geometryMapCollLocal, geometryMapCollLocal, transformAryLocal);

					//  replace collision object
					pNode->SetCollisionObject(createCollNode(geometryMapCollLocal, pCollNodeTmpl, pNode));
					pNode->RemoveChild(*ppIter);

					haveCollision |= true;

				}  //  if (pCollNodeTmpl == NULL)
			}  //  if (pRootTemplate != NULL)
		}
		//  NiNode (and derived classes?)
		else if (DynamicCast<NiNode>(*ppIter) != NULL)
		{
			haveCollision |= parseTreeCollision(DynamicCast<NiNode>(*ppIter), fileNameCollTmpl, geometryMapColl);
		}
	}  //  for (vector<NiAVObjectRef>::iterator  ppIter = srcChildList.begin(); ppIter != srcChildList.end(); ppIter++)

	return haveCollision;
}
开发者ID:Hashmi1,项目名称:NifConvert,代码行数:71,代码来源:NifCollisionUtility.cpp

示例15: AlignBiped

void NifImporter::AlignBiped(IBipMaster* master, NiNodeRef node)
{
#ifdef USE_BIPED
   NiNodeRef parent = node->GetParent();
   string name = node->GetName();
   vector<NiAVObjectRef> children = node->GetChildren();
   vector<NiNodeRef> childNodes = DynamicCast<NiNode>(children);

   TSTR s1 = FormatText("Processing %s:", name.c_str());
   TSTR s2 = FormatText("Processing %s:", name.c_str());
   INode *bone = GetNode(node);
   if (bone != NULL) 
   {
      if (uncontrolledDummies)
         BuildControllerRefList(node, ctrlCount);

      Matrix44 m4 = node->GetWorldTransform();
      Vector3 pos; Matrix33 rot; float scale;
      m4.Decompose(pos, rot, scale);
      Matrix3 m = TOMATRIX3(m4);
      Point3 p = m.GetTrans();
      Quat q(m);

      s1 += FormatText(" ( %s)", PrintMatrix3(m).data());
      if (strmatch(name, master->GetRootName()))
      {
         // Align COM
         //PosRotScaleNode(bone, p, q, 1.0f, prsPos);
         PosRotScaleBiped(master, bone, p, q, 1.0f, prsPos);
      }
      else if (INode *pnode = bone->GetParentNode())
      {
         // Reparent if necessary
         if (!strmatch(parent->GetName(), pnode->GetName())) {
            if (pnode = FindNode(parent)) {
               bone->Detach(0);
               pnode->AttachChild(bone);
            }
         }

         // Hack to scale the object until it fits
         for (int i=0; i<10; ++i) {
            float s = CalcScale(bone, node, childNodes);
            if (fabs(s-1.0f) < (FLT_EPSILON*100.0f))
               break;
            s1 += FormatText(" (%g)", s);
            master->SetBipedScale(TRUE, ScaleValue(Point3(s,s,s)), 0, bone);
         }
         PosRotScale prs = prsDefault;
         PosRotScaleBiped(master, bone, p, q, scale, prs);

         // Rotation with Clavicle is useless in Figure Mode using the standard interface
         //   I was tring unsuccessfully to correct for it
         //if (wildcmpi("Bip?? ? Clavicle", name.c_str())) {
         //   AngAxis a1 = CalcTransform(bone, node, childNodes);
         //   Matrix3 tm1 = GenerateRotMatrix(a1);
         //   Quat nq = TransformQuat(tm1, q);
         //   PosRotScaleNode(bone, p, nq, scale, prsRot);
         //}
      }
      s2 += FormatText(" ( %s)", PrintMatrix3(bone->GetNodeTM(0)).data());
   }
   else
   {
      ImportBones(node, false);
   }
   for (char *p = s1; *p != 0; ++p) if (isspace(*p)) *p = ' ';
   for (char *p = s2; *p != 0; ++p) if (isspace(*p)) *p = ' ';
   OutputDebugString(s1 + "\n");
   OutputDebugString(s2 + "\n");

   for (vector<NiNodeRef>::iterator itr = childNodes.begin(), end = childNodes.end(); itr != end; ++itr){
      AlignBiped(master, *itr);
   }
#endif
}
开发者ID:CruxAnsata,项目名称:max_nif_plugin,代码行数:76,代码来源:ImportSkeleton.cpp


注:本文中的NiNodeRef::GetChildren方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。