示例#1
0
文件: bodymesh.cpp 项目: yushiming/CS
    void CollectAllNodes (csHash<csRef<BodyChainNode>, CS::Animation::BoneID>& nodeHash,
                          BodyChainNode* rootNode)
    {
        nodeHash.Put (rootNode->GetAnimeshBone (), rootNode);

        for (size_t i = 0; i < rootNode->GetChildCount (); i++)
            CollectAllNodes (nodeHash, (BodyChainNode*) rootNode->GetChild (i));
    }
示例#2
0
bool celHNavStructBuilder::ParseMeshes (iDocumentNode* node, csHash<csRef<iSector>, const char*>& sectors, 
                                        celHNavStruct* navStruct, iVFS* vfs, iCelNavMeshParams* params)
{
  csRef<iEngine> engine = csLoadPluginCheck<iEngine>(objectRegistry, "crystalspace.engine.3d");
  if (!engine)
  {
    return false;
  }

  csRef<iDocumentNodeIterator> it = node->GetNodes("navmesh");
  while (it->HasNext())
  {
    csRef<iDocumentNode> navMeshNode = it->Next();

    // Get sector
    const char* sectorName = navMeshNode->GetAttributeValue("sector");
    csString sectorNameString(sectorName);
    if(!sectors.In(sectorName))
    {
      iSector* sector = engine->FindSector(sectorName);
      if(sector)
      {
          sectors.Put(sectorName, sector);
      }
      else
      {
          csString msg;
          msg.Format("invalid sector %s in navmesh\n", sectorName);
          CS_ASSERT_MSG(msg.GetData(),false);
      }
    }

    // Get navmesh
    int id = navMeshNode->GetAttributeValueAsInt("id");
    csString fileName;
    fileName = id;
    csRef<iFile> file = vfs->Open(fileName.GetDataSafe(), VFS_FILE_READ);
    csRef<iCelNavMeshBuilder> builder = csLoadPluginCheck<iCelNavMeshBuilder>(objectRegistry, "cel.navmeshbuilder");
    csRef<iCelNavMesh> navMesh = builder->LoadNavMesh(file);
    navStruct->AddNavMesh(navMesh);
  }
  return true;
}
示例#3
0
文件: stencil.cpp 项目: garinh/cs
void csStencilShadowCacheEntry::HandleEdge (EdgeInfo *e,
	csHash<EdgeInfo*>& edge_stack)
{
  double mplier = PI * 1e6;
  uint32 hash;
  hash = (uint32)(mplier * e->a.x + mplier * e->a.y + mplier * e->a.z);
  hash += (uint32)(mplier * e->b.x + mplier * e->b.y + mplier * e->b.z);

  csHash<EdgeInfo*>::Iterator it = edge_stack.GetIterator (hash);
  bool found = false;
  while (it.HasNext ()) 
  {
    EdgeInfo *t = it.Next ();
    if (e->a == t->b && e->b == t->a) 
    {
      found = true;
      edge_indices[edge_count*3 + 0] = e->ind_a;
      edge_indices[edge_count*3 + 1] = t->ind_b;
      edge_indices[edge_count*3 + 2] = t->ind_a;
      // edge_normals[edge_count] = t->norm;
      edge_midpoints[edge_count] = (t->a + t->b) / 2;
      edge_count ++;

      edge_indices[edge_count*3 + 0] = t->ind_a;
      edge_indices[edge_count*3 + 1] = e->ind_b;
      edge_indices[edge_count*3 + 2] = e->ind_a;
      // edge_normals[edge_count] = e->norm;
      edge_midpoints[edge_count] = (e->a + e->b) / 2;
      edge_count ++;
		    
      edge_stack.Delete (hash, t);
      break;
    }
  }
  if (!found) 
  { 
    edge_stack.Put (hash, e); 
  }
}
示例#4
0
bool csDriverDBReader::ParseConfigs (iDocumentNode* node)
{
  csRef<iDocumentNodeIterator> it (node->GetNodes ());
  while (it->HasNext())
  {
    csRef<iDocumentNode> child = it->Next();
    if (child->GetType() != CS_NODE_ELEMENT) continue;
    csStringID token = tokens.Request (child->GetValue ());

    switch (token)
    {
      case XMLTOKEN_CONFIG:
	{
	  const char* name = child->GetAttributeValue ("name");
	  if (!name)
	  {
	    db->Report (
	      CS_REPORTER_SEVERITY_WARNING,
	      child,
	      "<config> has no name");
	    return false;
	  }
	  csRef<csConfigDocument> cfg (configs.Get (name, 
	    (csConfigDocument*)0));
	  if (!cfg.IsValid ())
	  {
	    cfg.AttachNew (new csConfigDocument ());
	    configs.Put (name, cfg);
	  }
	  cfg->LoadNode (child, true, true);
	}
	break;
      default:
	db->ReportBadToken (child);
	return false;
    }
  }
  return true;
}