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


C++ csRef::GetParent方法代码示例

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


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

示例1: ParseMeshObj

void OptimiseData::ParseMeshObj(csArray<csString>& libsNeeded, csArray<csString>& materialsNeeded,
                                csString& mapInPath, csRef<iDocumentNode> meshobj)
{
  csRef<iDocumentNodeIterator> meshobjs = meshobj->GetNodes("meshobj");
  while(meshobjs->HasNext())
  {
    ParseMeshObj(libsNeeded, materialsNeeded, mapInPath, meshobjs->Next());
  }

  if(meshobj->GetNode("params"))
  {
    meshobj = meshobj->GetNode("params");
    if(meshobj->GetNode("factory"))
    {
      bool found = false;
      for(size_t i=0; i<meshFactsOut.GetSize(); i++)
      {
        if(csString(meshFactsOut[i]->GetRoot()->GetNode("library")->GetNode("meshfact")->GetAttributeValue("name")).Compare(meshobj->GetNode("factory")->GetContentsValue()))
        {
          libsNeeded.PushSmart(meshobj->GetNode("factory")->GetContentsValue());
          found = true;
        }
      }

      if(!found)
      {
        // Print error and mark data as incorrect.
        csFPrintf(stderr, "ERROR: Mesh object %s uses mesh factory %s but there is no factory data!\n",
          meshobj->GetAttributeValue("name"), meshobj->GetNode("factory")->GetContentsValue());
      }
    }
    if(meshobj->GetNode("material"))
    {
      bool found = false;
      for(size_t i=0; i<materials.GetSize(); i++)
      {
        if(csString(materials[i]->GetAttributeValue("name")).Compare(meshobj->GetNode("material")->GetContentsValue()))
        {
          materialsNeeded.PushSmart(meshobj->GetNode("material")->GetContentsValue());
          found = true;
        }
      }

      if(!found)
      {
        // Print error and mark data as incorrect.
        csFPrintf(stderr, "ERROR: Mesh object %s uses material %s but there is no such material declaration!\n",
          meshobj->GetAttributeValue("name"), meshobj->GetNode("material")->GetContentsValue());
      }
    }
  }
  else if(meshobj->GetNode("paramsfile"))
  {
    csString paramsPath = mapInPath + "/" + meshobj->GetNode("paramsfile")->GetContentsValue();
    csRef<iFile> file = vfs->Open(paramsPath, VFS_FILE_READ);
    csRef<iDocument> paramsDoc = docSys->CreateDocument();
    paramsDoc->Parse(file);
    meshobj = paramsDoc->GetRoot()->GetNode("params");
    if(meshobj->GetNode("factory"))
    {
      bool found = false;
      for(size_t i=0; i<meshFactsOut.GetSize(); i++)
      {
        if(csString(meshFactsOut[i]->GetRoot()->GetNode("library")->GetNode("meshfact")->GetAttributeValue("name")).Compare(meshobj->GetNode("factory")->GetContentsValue()))
        {
          libsNeeded.PushSmart(meshobj->GetNode("factory")->GetContentsValue());
          found = true;
        }
      }

      if(!found)
      {
        // Print error and mark data as incorrect.
        csFPrintf(stderr, "ERROR: Mesh object %s uses mesh factory %s but there is no factory data!\n",
          meshobj->GetParent()->GetAttributeValue("name"), meshobj->GetNode("factory")->GetContentsValue());
      }
    }
    if(meshobj->GetNode("material"))
    {
      bool found = false;
      for(size_t i=0; i<materials.GetSize(); i++)
      {
        if(csString(materials[i]->GetAttributeValue("name")).Compare(meshobj->GetNode("material")->GetContentsValue()))
        {
          materialsNeeded.PushSmart(meshobj->GetNode("material")->GetContentsValue());
          found = true;
        }
      }

      if(!found)
      {
        // Print error and mark data as incorrect.
        csFPrintf(stderr, "ERROR: Mesh object %s uses material %s but there is no such material declaration!\n",
          meshobj->GetParent()->GetAttributeValue("name"), meshobj->GetNode("material")->GetContentsValue());
      }
    }
  }
}
开发者ID:GameLemur,项目名称:Crystal-Space,代码行数:98,代码来源:optimisedata.cpp


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