Пример #1
0
PRBool
nsFT2FontNode::LoadNodeTable()
{
  int j;
  nsCOMPtr<nsIArray> arrayFC;
  nsCAutoString family, language;
  sFcs->GetFontCatalogEntries(family, language, 0, 0, 0, 0,
                              getter_AddRefs(arrayFC));
  if (!arrayFC)
    return PR_FALSE;
  PRUint32 count, i;
  arrayFC->GetLength(&count);
  for (i = 0; i < count; i++) {
    const char *charsetName;
    nsCOMPtr<nsITrueTypeFontCatalogEntry> fce = do_QueryElementAt(arrayFC, i);
    if (!fce)
      continue;
    PRUint32 flags, codePageRange1, codePageRange2;
    PRUint16 weight, width;
    fce->GetFlags(&flags);
    fce->GetWidth(&width);
    fce->GetWeight(&weight);
    fce->GetCodePageRange1(&codePageRange1);
    fce->GetCodePageRange2(&codePageRange2);
    if ((!flags&FCE_FLAGS_ISVALID)
        || (weight < 100) || (weight > 900) || (width > 8))
      continue;
    for (j=0; j<32; j++) {
      unsigned long bit = 1 << j;
      if (!(bit & codePageRange1))
        continue;
      charsetName = nsFreeType2::GetRange1CharSetName(bit);
      NS_ASSERTION(charsetName, "failed to get charset name");
      if (!charsetName)
        continue;
      LoadNode(fce, charsetName, nsnull);
    }
    for (j=0; j<32; j++) {
      unsigned long bit = 1 << j;
      if (!(bit & codePageRange2))
        continue;
      charsetName = nsFreeType2::GetRange2CharSetName(bit);
      if (!charsetName)
        continue;
      LoadNode(fce, charsetName, nsnull);
    }
  }
  return PR_TRUE;
}
Пример #2
0
LODNode* SceneLoader::LoadLODNode(QDomElement element)
{
  if (element.nodeName() != QString ("node") ||
      QString::compare(element.attribute("type"), "lod", Qt::CaseInsensitive) != 0)
    {
      printf ("ceXMLDataLoader::LoadLODNode: Illegal data format: '%s' != 'group'\n", element.attribute("type").toStdString().c_str()); fflush (stdout);
    }

  LODNode* lod = new LODNode ();

  QString name = element.attribute("name");
  if (!name.isNull())
    {
      lod->SetName(name.toStdString());
    }

  for (QDomElement groupElement = element.firstChildElement();
       !groupElement.isNull();
       groupElement = groupElement.nextSiblingElement())

    {
      ceNode* node = LoadNode (groupElement);
      if (node)
        {
          lod->Get().Add(node);
        }
    }
  lod->GetSolver()->SetNum(lod->Get().GetNumberOfLevels());

  lod->UpdateBoundingBox();
  return lod;
}
Пример #3
0
	int FbxLoader::LoadFbx(const char* fbxName)
	{
		m_fbxManager = FbxManager::Create();
		FbxIOSettings *ios = FbxIOSettings::Create(m_fbxManager, IOSROOT);
		m_fbxManager->SetIOSettings(ios);
		FbxImporter* lImporter = FbxImporter::Create(m_fbxManager, "");

		if (!lImporter->Initialize(fbxName, -1, m_fbxManager->GetIOSettings())) {
			printf("Call to FbxImporter::Initialize() failed.\n");
			printf("Error returned: %s\n\n", lImporter->GetStatus().GetErrorString());
			return -1;
		}

		FbxScene* lScene = FbxScene::Create(m_fbxManager, "myScene");
		lImporter->Import(lScene);
		lImporter->Destroy();

		m_rootNode = lScene->GetRootNode();
		if (m_rootNode) {
			m_firstNode = m_rootNode->GetChild(0);
			for (int i = 0; i < m_rootNode->GetChildCount(); i++)
				LoadNode(m_rootNode->GetChild(i));
		}
		m_animEvaluator = lScene->GetAnimationEvaluator();
		return 0;
	}
Пример #4
0
		ZD_STATUS Language::LoadNode(JsonBox::Value &node, const std::string &prefix)
		{
			if (node.isObject())
			{
				JsonBox::Object obj = node.getObject();

				for (auto &i : obj)
				{
					std::stringstream new_prefix;

					if (prefix.length() > 0)
					{
						new_prefix << prefix << m_delimiter;						
					}

					new_prefix << i.first;

					LoadNode(i.second, new_prefix.str());
				}
			}
			else if (node.isString())
			{
				m_words[prefix] = node.getString();
			}
			else if (node.isInteger())
			{
				m_words[prefix] = Helpers::String::To(node.getInt());
			}
			return ZD_NOERROR;
		}
Пример #5
0
bool MaterialGraph::LoadFromFile(const FilePath & pathname)
{
    
    YamlParser * materialFileParser = YamlParser::Create(pathname);
    if (!materialFileParser)return false;
    
    materialPathname = pathname;
        
    
    const YamlNode * rootNode = materialFileParser->GetRootNode();
    const YamlNode * materialNode = rootNode->Get("material");
    
    const YamlNode * vertexShaderFileNode = materialNode->Get("vertexShader");
    vertexShaderFilename = vertexShaderFileNode->AsString();
    
    const YamlNode * pixelShaderFileNode = materialNode->Get("pixelShader");
    pixelShaderFilename = pixelShaderFileNode->AsString();
    
    const YamlNode * nodes = rootNode->Get("nodes");
    if (nodes && nodes->GetType() == YamlNode::TYPE_ARRAY)
    {
        for (uint32 k = 0; k < nodes->GetCount(); ++k)
        {
            const YamlNode * graphNode = nodes->Get(k);
            bool result = LoadNode(graphNode);
            if (!result)break;
        }
    }
    
    SafeRelease(materialFileParser);
    return true;
}
Пример #6
0
GroupNode* SceneLoader::LoadGroupNode(QDomElement element)
{
  if (element.nodeName() != QString ("node") ||
      QString::compare(element.attribute("type"), "group", Qt::CaseInsensitive) != 0)
    {
      printf ("ceXMLDataLoader::LoadGroupNode: Illegal data format: '%s' != 'group'\n", element.nodeName().toStdString().c_str()); fflush (stdout);
    }

  GroupNode* group = new GroupNode();

  QString name = element.attribute("name");
  if (!name.isNull())
    {
      group->SetName(name.toStdString());
    }

  for (QDomElement groupElement = element.firstChildElement();
       !groupElement.isNull();
       groupElement = groupElement.nextSiblingElement())

    {
      ceNode* node = LoadNode (groupElement);
      if (node)
        {
          group->AddNode(node);
        }
    }

  group->UpdateBoundingBox();
  return group;
}
// copy id node tree in visual scene or generate the names
NodeHPChecker::TreeNode * NodeHPChecker::LoadNode(domNode *pDomNode, NodeHPChecker::TreeNode *pParentNode)
{
	TreeNode * pNode = new TreeNode();

	pNode->SetParent(pParentNode);

	// check id of node
	if ( pDomNode->getID() == NULL ) // no ID in this node
	{
		GeneratingName(pNode);
	}
	else
	{
		// put id of node to it
		pNode->SetID( std::string( pDomNode->getID() ) );
	}

	// transverse children of current node
	domNode_Array& aNodes = pDomNode->getNode_array();

	for ( size_t i = 0; i < aNodes.getCount(); i++ ) 
	{
		pNode->AppendChildren( LoadNode(aNodes.get(i), pNode) );
	}

	return pNode;
}
bool NodeHPChecker::InitRoots()
{
	for (int j = 0; j < NUM_TREES;j++)
	{
		pRoot[j] = new TreeNode();

		GeneratingName(pRoot[j]);

		// new root pointers
		domNode_Array& aNodes = pVisualScene[j]->getNode_array();

		// add each node to root
		for ( size_t i = 0; i < aNodes.getCount(); i++ ) 
		{
			TreeNode * pChild = new TreeNode();

			// Load current dom node
			// Append child
			pRoot[j]->AppendChildren( LoadNode(aNodes.get(i), pRoot[j]) );

			pChild->SetParent(pRoot[j]);
		}

		// reset index:
		giIndexNoName = 0;
	}

	// sort each tree
	SortChildren();

	return true;
}
Пример #9
0
	void FbxUtil::LoadScene(const std::string &filePath, const std::shared_ptr<SceneNode> &rootNode, float scaleFactor, unsigned int options)
	{
		FbxManager* sdkManager = FbxManager::Create();

		FbxIOSettings* ios = FbxIOSettings::Create(sdkManager, IOSROOT);
		sdkManager->SetIOSettings(ios);

		FbxImporter* importer = FbxImporter::Create(sdkManager, "");
		m_ScaleFactor = scaleFactor;
		m_Options = options;

		if (importer->Initialize(filePath.c_str(), -1, sdkManager->GetIOSettings()))
		{
			FbxScene* lScene = FbxScene::Create(sdkManager, "");

			importer->Import(lScene);

			importer->Destroy();

			FbxNode* lRootNode = lScene->GetRootNode();

			if (lRootNode)
			{
				for (int i = 0; i < lRootNode->GetChildCount(); i++)
					LoadNode(rootNode, lRootNode->GetChild(i));

				rootNode->Recompose();
			}
		}
		else
			ASSERT_MSG(false, "Error: " << importer->GetStatus().GetErrorString());

		// Destroy the SDK manager and all the other objects it was handling.
		sdkManager->Destroy();
	}
Пример #10
0
/**
 * Load Road Network Data
 */
void loadData(char *path)
{
	readBuffer = (char *)malloc(nowSize);
	LoadNode(path);
	LoadEdge(path);
	LoadNet(path);
}
Пример #11
0
void LoadScene(TiXmlElement *element)
{
    for ( TiXmlElement *child = element->FirstChildElement(); child!=NULL; child = child->NextSiblingElement() ) {
        
        if ( COMPARE( child->Value(), "background" ) ) {
            Color c(1,1,1);
            ReadColor( child, c );
            background.SetColor(c);
            printf("Background %f %f %f\n",c.r,c.g,c.b);
            background.SetTexture( ReadTexture(child) );
        } else if ( COMPARE( child->Value(), "environment" ) ) {
            Color c(1,1,1);
            ReadColor( child, c );
            environment.SetColor(c);
            printf("Environment %f %f %f\n",c.r,c.g,c.b);
            environment.SetTexture( ReadTexture(child) );
        } else if ( COMPARE( child->Value(), "object" ) ) {
            LoadNode( &rootNode, child );
        } else if ( COMPARE( child->Value(), "material" ) ) {
            LoadMaterial( child );
        } else if ( COMPARE( child->Value(), "light" ) ) {
            LoadLight( child );
        }
    }
}
Пример #12
0
void BackGroundLayer::initInterface()
{
    this->setName("BackGroundLayer");
    MainScene::GetSceneInstance()->addChild(this);
    LoadSpriteCache(); //先预读精灵帧
    LoadNode();
    LoadAnimationCache();
}
Пример #13
0
ceNode* SceneLoader::Load(QDomElement element)
{
  if (element.nodeName() != "node")
    {
      return 0;
    }
  return LoadNode (element);
}
Пример #14
0
	void FbxLoader::LoadNode(FbxNode* pNode)
	{
		for (int i = 0; i < pNode->GetNodeAttributeCount(); i++)
			LoadAttribute(pNode->GetNodeAttributeByIndex(i));

		// Recursively print the children.
		for (int j = 0; j < pNode->GetChildCount(); j++)
			LoadNode(pNode->GetChild(j));
	}
Пример #15
0
	bool Model::LoadFromFile(std::string filepath)
	{
		// Clear any previously loaded data.
		Clear();

		// Create an instance of the ASSIMP importer.
		Assimp::Importer importer;

		// Have ASSIMP read the file.
		const aiScene* assimpScene = importer.ReadFile(
			filepath.c_str(),
			aiProcess_Triangulate | aiProcess_GenSmoothNormals | aiProcess_JoinIdenticalVertices | aiProcess_RemoveRedundantMaterials | aiProcess_FlipUVs | aiProcess_OptimizeGraph | aiProcess_OptimizeMeshes
		);

		// Check that the file was read successfully.
		if (assimpScene)
		{
			// Get the root node.
			const aiNode* assimpRootNode = assimpScene->mRootNode;

			if (assimpRootNode)
			{
				// Get the path to the parent directory.
				// This is used for determining the full path to textures.
				const std::string directoryPath = filepath.substr(0, filepath.find_last_of('/'));

				// Load the materials.
				LoadMaterials(assimpScene, directoryPath);

				// Load the nodes recursively.
				LoadNode(assimpRootNode, assimpScene, nullptr);

				// Load the node keyframes.
				LoadNodeKeyframes(assimpScene);

				// Success!
				m_name = filepath;
				return true;
			}
			else
			{
				std::cerr << "Failed loading model \"" << filepath
					<< "\" due to missing root node" << std::endl;
				return false;
			}
		}
		else
		{
			std::cerr << "Failed loading model: \"" << filepath
				<< "\" due to error: " << importer.GetErrorString()
				<< std::endl;

			return false;
		}
	}
Пример #16
0
//void Import::LoadNode (INode* maxParent, const dMatrix& parentMatrix, dModel* model, dBone* node, const GeometryCache& meshCache, Mtl *mtl)
void Import::LoadNodes (dScene& scene, const GeometryCache& meshCache, Mtl *mtl, MaxNodeChache& maxNodeCache)
{
    dScene::dTreeNode* const root = scene.GetRootNode();

    for (void* ptr = scene.GetFirstChild(root); ptr; ptr = scene.GetNextChild(root, ptr) ) {
        dScene::dTreeNode* node = scene.GetNodeFromLink(ptr);
        dNodeInfo* info = scene.GetInfoFromNode(node);
        if (info->IsType(dSceneNodeInfo::GetRttiType())) {
            LoadNode (scene, NULL, node, meshCache, mtl, maxNodeCache);
        }
    }
}
Пример #17
0
void LoadScene(TiXmlElement *element)
{
    for ( TiXmlElement *child = element->FirstChildElement(); child!=NULL; child = child->NextSiblingElement() ) {
        
        if ( COMPARE( child->Value(), "object" ) ) {
            //cout<<"Object...................";
            LoadNode( &rootNode, child );
        } else if ( COMPARE( child->Value(), "material" ) ) {
            LoadMaterial( child );
        } else if ( COMPARE( child->Value(), "light" ) ) {
            LoadLight( child );
        }
    }
}
Пример #18
0
void LoadNode(Node *parent, TiXmlElement *element, int level)
{
    Node *node = new Node;
    parent->AppendChild(node);
    
    // name
    const char* name = element->Attribute("name");
    node->SetName(name);
    PrintIndent(level);
    printf("object [");
    if ( name ) printf("%s",name);
    printf("]");
    
    // type
    const char* type = element->Attribute("type");
    if ( type ) {
        if ( COMPARE(type,"sphere") ) {
            node->SetObject( &theSphere );
            printf(" - Sphere");
        } else {
            printf(" - UNKNOWN TYPE");
        }
    }
    
    // type
    const char* mtlName = element->Attribute("material");
    if ( mtlName ) {
        printf(" <%s>", mtlName);
        NodeMtl nm;
        nm.node = node;
        nm.mtlName = mtlName;
        nodeMtlList.push_back(nm);
    }
    
    printf("\n");
    
    
    for ( TiXmlElement *child = element->FirstChildElement(); child!=NULL; child = child->NextSiblingElement() ) {
        if ( COMPARE( child->Value(), "object" ) ) {
            LoadNode(node,child,level+1);
        }
    }
    LoadTransform( node, element, level );
    
}
Пример #19
0
	void FbxParser::LoadScene(const std::string & filePath, GameObjectPtr rootNode)
	{
		mFbxManager = FbxManager::Create();
		auto ios = FbxIOSettings::Create(mFbxManager, IOSROOT);
		mFbxManager->SetIOSettings(ios);

		auto importer = FbxImporter::Create(mFbxManager, "");
		auto pos = filePath.find_last_of("/");
		mFbxFolder = (std::string::npos == pos) ? "" : filePath.substr(0, pos + 1);

		Utility::Printf("FbxFolder %s", mFbxFolder.c_str());

		if (importer->Initialize(filePath.c_str(), -1, mFbxManager->GetIOSettings()))
		{
			mFbxScene = FbxScene::Create(mFbxManager, "");
			bool result = importer->Import(mFbxScene);
			importer->Destroy();


			if (result)
			{
				auto& globalSetting = mFbxScene->GetGlobalSettings();

				FbxGeometryConverter geomConverter(mFbxManager);
				geomConverter.Triangulate(mFbxScene, true);

				auto fbxRootNode = mFbxScene->GetRootNode();

				if (fbxRootNode)
				{
					for (int i = 0; i < fbxRootNode->GetChildCount(); ++i)
					{
						LoadNode(rootNode, fbxRootNode->GetChild(i));
					}
					rootNode->FreshData(true);
				}
			}
		}
		else
		{
			auto status = importer->GetStatus();
			auto str = status.GetErrorString();
			Utility::Printf("FBX File Cant Load %s %s", filePath.c_str(), str);
		}
	}
Пример #20
0
// LoadNode (FileNode)
//------------------------------------------------------------------------------
/*static*/ bool Node::LoadNode( IOStream & stream, FileNode * & fileNode )
{
	Node * node;
	if ( !LoadNode( stream, node ) )
	{
		return false;
	}
    if ( node == nullptr )
    {
        fileNode = nullptr;
        return true;
    }
	if ( !node->IsAFile() )
	{
		return false;
	}
	fileNode = node->CastTo< FileNode >();
	return ( fileNode != nullptr );
}
Пример #21
0
// LoadNode (CompilerNode)
//------------------------------------------------------------------------------
/*static*/ bool Node::LoadNode( IOStream & stream, CompilerNode * & compilerNode )
{
	Node * node;
	if ( !LoadNode( stream, node ) )
	{
		return false;
	}
    if ( node == nullptr )
    {
        compilerNode = nullptr;
        return true;
    }
	if ( node->GetType() != Node::COMPILER_NODE )
	{
		return false;
	}
	compilerNode = node->CastTo< CompilerNode >();
	return true;
}
Пример #22
0
		ZD_STATUS Language::Deserialize(JsonBox::Value &root)
		{
			if (!root["info"].isObject() || 
				!root["locale"].isObject())
			{
				return ZD_ERROR_BAD_DATA;
			}

			JsonBox::Object info = root["info"].getObject();			

			if (!info["language"].isString() ||
				!info["title"].isString())
			{
				return ZD_ERROR_BAD_DATA;
			}

			m_language = info["language"].getString();
			m_title = info["title"].getString();

			return LoadNode(root["locale"]);
		}
Пример #23
0
	void FbxUtil::LoadNode(const SceneNode::Ptr &ntNode, FbxNode* fbxNode)
	{
		SceneNode::Ptr childNode = SceneNode::Create(fbxNode->GetName());

		// copy transforms.
		FbxQuaternion fbxQ;
		fbxQ.ComposeSphericalXYZ(fbxNode->LclRotation.Get());
		FbxDouble3 fbxT = fbxNode->LclTranslation.Get();
		FbxDouble3 fbxS = fbxNode->LclScaling.Get();

		Vector4 furyT((float)fbxT.mData[0] * m_ScaleFactor, (float)fbxT.mData[1] * m_ScaleFactor, (float)fbxT.mData[2] * m_ScaleFactor, 1.0f);
		Vector4 furyS((float)fbxS.mData[0] * m_ScaleFactor, (float)fbxS.mData[1] * m_ScaleFactor, (float)fbxS.mData[2] * m_ScaleFactor, 1.0f);
		Quaternion furyR((float)fbxQ.mData[0], (float)fbxQ.mData[1], (float)fbxQ.mData[2], (float)fbxQ.mData[3]);

		childNode->SetLocalPosition(furyT);
		childNode->SetLocalRoattion(furyR);
		childNode->SetLocalScale(furyS);

		// add to scene graph
		ntNode->AddChild(childNode);

		// read Components
		FbxNodeAttribute* fbxNodeAttr = fbxNode->GetNodeAttribute();
		if (fbxNodeAttr != NULL)
		{
			FbxNodeAttribute::EType fbxNodeAttrType = fbxNodeAttr->GetAttributeType();
			if (fbxNodeAttrType == FbxNodeAttribute::eMesh)
			{
				LoadMesh(childNode, fbxNode);
			}
			else if (fbxNodeAttrType == FbxNodeAttribute::eLight)
			{
				LoadLight(childNode, fbxNode);
			}
		}

		// read child nodes.
		for (int i = 0; i < fbxNode->GetChildCount(); i++)
			LoadNode(ntNode, fbxNode->GetChild(i));
	}
Пример #24
0
CElement* CMapManager::LoadMapData ( CResource& Loader, CElement& Parent, CXMLNode& Node )
{
    // Load the elements
    vector < CElement* > ElementsAdded;
    CElement* pLoadedRoot = LoadNode ( Loader, Node, &Parent, &ElementsAdded, false );
    if ( pLoadedRoot )
    {
        // Add all the elements that are entities to a sync packet
        CEntityAddPacket AddPacket;
        vector < CElement* > ::const_iterator iter = ElementsAdded.begin ();
        for ( ; iter != ElementsAdded.end (); iter++ )
        {
            // Is it a per-player entity? Sync it. Otherwize add it to the packet.
            if ( IS_PERPLAYER_ENTITY ( *iter ) )
            {
                static_cast < CPerPlayerEntity* > ( *iter )->Sync ( true );
            }
            else
            {
                AddPacket.Add ( *iter );
            }
        }

        // Send it to everyone
        m_pPlayerManager->BroadcastOnlyJoined ( AddPacket );
        return pLoadedRoot;
    }

    // If unsuccessfull, destroy the new elements. Remember removing it from our element group.
    CElementGroup* pElementGroup = Loader.GetElementGroup ();
    vector < CElement* > ::const_iterator iter = ElementsAdded.begin ();
    for ( ; iter != ElementsAdded.end (); iter++ )
    {
        pElementGroup->Remove ( *iter );
        delete *iter;
    }

    // Failed
    return NULL;
}
Пример #25
0
bool _XKeyframeController::LoadKey(FILE* pFile)
{
//	CHAR ShortFilename[512];
//	memset( ShortFilename, 0, sizeof(TCHAR)*512 );
//	GetFileNameFromPathString( ShortFilename, szFilename );

	_LPXM_KEYFRAME lpKeyframe = new _XM_KEYFRAME;
//	strcpy(lpKeyframe->strName, ShortFilename);
	lpKeyframe->fMaxTime = 0.f;

	DWORD dwVersion;
	char cHeader[MAX_PATH];
	memset(cHeader, 0, MAX_PATH);

	fread(cHeader,		3,		sizeof(char),			pFile);
	fread(&dwVersion,	1,		sizeof(DWORD),			pFile);

	fread(&m_nNodeCount,	1,	sizeof(int),			pFile);

	lpKeyframe->lpSubNode = new _XM_SUBNODE[m_nNodeCount];
	memset(lpKeyframe->lpSubNode, 0, sizeof(_XM_SUBNODE) * m_nNodeCount);

	for (int i = 0; i < m_nNodeCount; ++i)
	{
		D3DXMatrixIdentity(&lpKeyframe->lpSubNode[i].matTM);

		LoadNode(pFile, &lpKeyframe->lpSubNode[i]);
		fread(&lpKeyframe->lpSubNode[i].fMaxTime,	1,	sizeof(float),		pFile);
		if (lpKeyframe->fMaxTime < lpKeyframe->lpSubNode[i].fMaxTime)
		{
			lpKeyframe->fMaxTime = lpKeyframe->lpSubNode[i].fMaxTime;
		}
	}

	m_lpCurKeyframe = lpKeyframe;
	m_svKeyframe.push_back(lpKeyframe);

	return true;
}
Пример #26
0
void LoadNode(Node *parent, TiXmlElement *element, int level)
{
    Node *node = new Node;
    parent->AppendChild(node);
    
    // name
    const char* name = element->Attribute("name");
    node->SetName(name);
    PrintIndent(level);
    printf("object [");
    if ( name ) printf("%s",name);
    printf("]");
    
    // type
    const char* type = element->Attribute("type");
    if ( type ) {
        if ( COMPARE(type,"sphere") ) {
            node->SetObject( &theSphere );
            printf(" - Sphere");
        } else if ( COMPARE(type,"plane") ) {
            node->SetObject( &thePlane );
            printf(" - Plane");
        } else if ( COMPARE(type,"obj") ) {
            printf(" - OBJ");
            Object *obj = objList.Find(name);
            if ( obj == NULL ) {    // object is not on the list, so we should load it now
                TriObj *tobj = new TriObj;
                if ( ! tobj->Load( name ) ) {
                    printf(" -- ERROR: Cannot load file \"%s.\"", name);
                    delete tobj;
                } else {
                    objList.Append(tobj,name);  // add to the list
                    obj = tobj;
                }
            }
            node->SetObject( obj );
        } else {
            printf(" - UNKNOWN TYPE");
        }
    }
    
    // type
    const char* mtlName = element->Attribute("material");
    if ( mtlName ) {
        printf(" <%s>", mtlName);
        NodeMtl nm;
        nm.node = node;
        nm.mtlName = mtlName;
        nodeMtlList.push_back(nm);
    }
    
    printf("\n");
    
    
    for ( TiXmlElement *child = element->FirstChildElement(); child!=NULL; child = child->NextSiblingElement() ) {
        if ( COMPARE( child->Value(), "object" ) ) {
            LoadNode(node,child,level+1);
        }
    }
    LoadTransform( node, element, level );
    
}
Пример #27
0
void
nsFT2FontNode::GetFontNames(const char* aPattern, nsFontNodeArray* aNodes)
{
  int j;
  PRBool rslt;
  PRUint32 count, i;
  char *pattern, *foundry, *family, *charset, *encoding;
  const char *charSetName;
  nsFontNode *node;
  nsCOMPtr<nsIArray> arrayFC;
  nsCAutoString familyTmp, languageTmp;

  FONT_CATALOG_PRINTF(("looking for FreeType font matching %s", aPattern));
  nsCAutoString patt(aPattern);
  ToLowerCase(patt);
  pattern = strdup(patt.get());
  NS_ASSERTION(pattern, "failed to copy pattern");
  if (!pattern)
    goto cleanup_and_return;

  rslt = ParseXLFD(pattern, &foundry, &family, &charset, &encoding);
  if (!rslt)
    goto cleanup_and_return;

  // unable to handle "name-charset-*"
  if (charset && !encoding) {
    goto cleanup_and_return;
  }

  if (family)
    familyTmp.Assign(family);

  sFcs->GetFontCatalogEntries(familyTmp, languageTmp, 0, 0, 0, 0,
                              getter_AddRefs(arrayFC));
  if (!arrayFC)
    goto cleanup_and_return;
  arrayFC->GetLength(&count);
  for (i = 0; i < count; i++) {
    nsCOMPtr<nsITrueTypeFontCatalogEntry> fce = do_QueryElementAt(arrayFC, i);
    if (!fce)
      continue;
    nsCAutoString foundryName, familyName;
    PRUint32 flags, codePageRange1, codePageRange2;
    PRUint16 weight, width;
    fce->GetFamilyName(familyName);
    fce->GetFlags(&flags);
    fce->GetWidth(&width);
    fce->GetWeight(&weight);
    fce->GetCodePageRange1(&codePageRange1);
    fce->GetCodePageRange2(&codePageRange2);
    if (!charset) { // get all encoding
      FONT_CATALOG_PRINTF(("found FreeType %s-%s-*-*", foundryName.get(),
                           familyName.get()));
      for (j=0; j<32; j++) {
        unsigned long bit = 1 << j;
        if (bit & codePageRange1) {
          charSetName = nsFreeType2::GetRange1CharSetName(bit);
          NS_ASSERTION(charSetName, "failed to get charset name");
          if (!charSetName)
            continue;
          node = LoadNode(fce, charSetName, aNodes);
        }
        if (bit & codePageRange2) {
          charSetName = nsFreeType2::GetRange2CharSetName(bit);
          if (!charSetName)
            continue;
          LoadNode(fce, charSetName, aNodes);
        }
      }
      if (foundryName.IsEmpty() && !familyName.IsEmpty() && flags&FCE_FLAGS_SYMBOL) {
        // the "registry-encoding" is not used but LoadNode will fail without
        // some value for this
        LoadNode(fce, "symbol-fontspecific", aNodes);
      }
    }

    if (charset && encoding) { // get this specific encoding
      PRUint32 cpr1_bits, cpr2_bits;
      nsCAutoString charsetName(charset);
      charsetName.Append('-');
      charsetName.Append(encoding);
      CharSetNameToCodeRangeBits(charsetName.get(), &cpr1_bits, &cpr2_bits);
      if (!(cpr1_bits & codePageRange1)
          && !(cpr2_bits & codePageRange2))
        continue;
      FONT_CATALOG_PRINTF(("found FreeType -%s-%s-%s",
                           familyName.get(),charset,encoding));
      LoadNode(fce, charsetName.get(), aNodes);
    }
  }

  FREE_IF(pattern);
  return;

cleanup_and_return:
  FONT_CATALOG_PRINTF(("nsFT2FontNode::GetFontNames failed"));
  FREE_IF(pattern);
  return;
}
Пример #28
0
void Import::LoadNode (dScene& scene, INode* maxParent, dScene::dTreeNode* node, const GeometryCache& meshCache, Mtl *mtl, MaxNodeChache& maxNodeCache)
{
    dScene::dTreeNode* geometryNode = NULL;
    for (void* ptr = scene.GetFirstChild(node); ptr; ptr = scene.GetNextChild(node, ptr) ) {
        dScene::dTreeNode* node = scene.GetNodeFromLink(ptr);
        dNodeInfo* info = scene.GetInfoFromNode(node);
        if (info->IsType(dGeometryNodeInfo::GetRttiType())) {
            geometryNode = node;
            break;
        }
    }


    INode* maxNode = NULL;
    if (geometryNode) {
//		maxNode = CreateMaxMeshNode (mtl, &geom[0]->GetInfo(), meshCache);
        maxNode = CreateMaxMeshNode (scene, mtl, geometryNode, meshCache);
        maxNodeCache.Insert (maxNode, geometryNode);
    } else {
        maxNode = CreateMaxHelperNode ();
    }

    _ASSERTE (maxNode);
    maxNodeCache.Insert (maxNode, node);

    if (maxParent) {
        maxParent->AttachChild(maxNode, 1);
    }

    dSceneNodeInfo* sceneInfo = (dSceneNodeInfo*)scene.GetInfoFromNode(node);

    TCHAR name[128];
    TCHAR tmp[128];
    strcpy (tmp, sceneInfo->GetName());
    for (int i = 0; tmp[i]; i ++) {
        if (isspace(tmp[i])) {
            tmp[i] = '_';
        }
    }
    strcpy (name, tmp);
    for (int i = 1; m_ip->GetINodeByName(name); i ++) {
        sprintf (name, "%s_%02d", tmp, i);
//		node->SetNameID(name);
    }
    maxNode->SetName(name);

    dMatrix transform (sceneInfo->GetTransform());
    dMatrix matrix;
    for (int i = 0; i < 4; i ++) {
        for (int j = 0; j < 4; j ++) {
            matrix[i][j] = transform[i][j];
        }
    }

    Matrix3 maxMatrix (GetMatrixFromdMatrix (matrix));
//	maxMatrix.SetRow (0, *((Point3*) &matrix[0]));
//	maxMatrix.SetRow (1, *((Point3*) &matrix[1]));
//	maxMatrix.SetRow (2, *((Point3*) &matrix[2]));
//	maxMatrix.SetRow (3, *((Point3*) &matrix[3]));
    maxNode->SetNodeTM(0, maxMatrix);

    for (void* ptr = scene.GetFirstChild(node); ptr; ptr = scene.GetNextChild(node, ptr) ) {
        dScene::dTreeNode* node = scene.GetNodeFromLink(ptr);
        dNodeInfo* info = scene.GetInfoFromNode(node);
        if (info->IsType(dSceneNodeInfo::GetRttiType())) {
            LoadNode (scene, maxNode, node, meshCache, mtl, maxNodeCache);
        }
    }
}
Пример #29
0
	void Model::LoadNode(const aiNode* assimpNode, const aiScene* assimpScene, std::shared_ptr<Node> parentNode)
	{
		// Get the node's name.
		const std::string name(assimpNode->mName.data);

		// Calculate the local bind pose transformation matrix.
		const glm::mat4 localBindTransformationMatrix =
			glm::transpose(ConvertToMat4(assimpNode->mTransformation));

		// Create our own new node.
		// We will be populating this with the data retrieved from ASSIMP.
		std::shared_ptr<Node> node = std::make_shared<Node>(name, localBindTransformationMatrix);

		// Get the number of meshes in the ASSIMP node.
		const unsigned int numMeshesInNode = assimpNode->mNumMeshes;

		// For every mesh in the ASSIMP node...
		for (unsigned int m = 0; m < numMeshesInNode; ++m)
		{
			// Get the ASSIMP mesh.
			const unsigned int assimpMeshIndex = assimpNode->mMeshes[m];
			const aiMesh* assimpMesh = assimpScene->mMeshes[assimpMeshIndex];

			// Create our own new mesh.
			std::shared_ptr<Node::Mesh> mesh = std::make_shared<Node::Mesh>();

			// Get the number of vertices that compose the mesh.
			const unsigned int numVertices = assimpMesh->mNumVertices;

			// Set the material that is applied to the mesh.
			mesh->SetMaterial(m_materials[assimpMesh->mMaterialIndex]);

			// Populate the mesh's vertex positions, normals and texture
			// coordinates.
			for (unsigned int v = 0; v < numVertices; ++v)
			{
				mesh->AddVertexPosition(ConvertToVec3(assimpMesh->mVertices[v]));
				mesh->AddVertexNormal(ConvertToVec3(assimpMesh->mNormals[v]));
				mesh->AddVertexTextureCoordinates(ConvertToVec3(assimpMesh->mTextureCoords[0][v]));
			}

			// Get the number of faces and indices in the mesh.
			const unsigned int numFaces = assimpMesh->mNumFaces;

			// Populate the mesh's faces.
			for (unsigned int f = 0; f < numFaces; ++f)
			{
				// Get the ASSIMP face.
				const aiFace& assimpFace = assimpMesh->mFaces[f];

				// Ensure that we are dealing with triangular faces.
				if (assimpFace.mNumIndices == 3)
				{
					for (unsigned int i = 0; i < 3; ++i)
					{
						mesh->AddVertexIndex(static_cast<unsigned int>(assimpFace.mIndices[i]));
					}
				}
				else
				{
					std::cout << "WARNING: Face was not triangular" << std::endl;
				}
			}

			// Update the mesh's buffer objects.
			// This sends the mesh data over to the graphics card.
			mesh->UpdateBuffers();

			// Add the mesh to the node.
			node->AddMesh(mesh);
		}

		// Add the node to the model.
		if (!parentNode)
		{
			// The created node doesn't have a parent node. Therefore, it must
			// be the root node.
			m_rootNode = node;
		}
		else
		{
			// Add the created node as a child to its parent node.
			parentNode->AddChildNode(node);
		}

		// Get the number of ASSIMP child nodes.
		const unsigned int numChildNodes = assimpNode->mNumChildren;

		// Recursively load child nodes.
		for (unsigned int n = 0; n < numChildNodes; ++n)
		{
			LoadNode(assimpNode->mChildren[n], assimpScene, node);
		}
	}
Пример #30
0
HRESULT KG3DTerrainRoad::LoadFromFile(const char cszFileName[])
{
	//return E_FAIL;
    HRESULT hr = E_FAIL;	
	int nRetCode = false;
	TCHAR FileName[MAX_PATH]; 
	_RoadHead RoadHead;
	DWORD nSize;
	D3DXVECTOR3* pNodePos = NULL;
	IFile* pFile = NULL;
	pFile = g_OpenFile(cszFileName);
	KG_PROCESS_ERROR(pFile);

	nSize = pFile->Read(&RoadHead,sizeof(_RoadHead));//fread(&RoadData,sizeof(_RoadData),1,pFile);
	
	m_scName        = RoadHead.scName;
	m_scTextureName = RoadHead.scTextureName;
	m_fBendModulus  = RoadHead.fBendModulus;
	m_fEdgeModulus  = RoadHead.fEdgeModulus;
	m_fTexDensity   = RoadHead.fTexDensity;
	m_fBlendLength  = RoadHead.fBlendLength;
	m_fWidth        = RoadHead.fWidth;
	m_nID           = RoadHead.nID;
	m_fNodeSize     = RoadHead.fNodeSize;
	m_nSegmentLength= RoadHead.dwSegmentLength;
	wsprintf(FileName,"%s", m_scTextureName.c_str());
	LoadRoadTexture(FileName);
	if (!g_bClient)
	{
		nRetCode = pFile->Seek(RoadHead.dwParentTerrainBlock, SEEK_SET);
		KGLOG_PROCESS_ERROR(nRetCode != -1);
		for (int nT= 0; nT < (int)RoadHead.dwNumParentBlock; nT++)
		{
			TerrainBlockInfo TBI;
			pFile->Read(&TBI,sizeof(TerrainBlockInfo));
			m_vecParentTerrainBlock.push_back(TBI);
		}

		nRetCode = pFile->Seek(RoadHead.dwNodePosBlock, SEEK_SET);//fseek(pFile,RoadData.dwNodePosBlock, SEEK_SET);
		KGLOG_PROCESS_ERROR(nRetCode != -1);
		pNodePos = new D3DXVECTOR3[RoadHead.dwNumOfNode];
		KGLOG_PROCESS_ERROR(pNodePos);
		nSize = pFile->Read(pNodePos,sizeof(D3DXVECTOR3)*RoadHead.dwNumOfNode);//fread(RoadData.pNodePos,sizeof(D3DXVECTOR3),RoadData.dwNumOfNode,pFile);
		LoadNode(RoadHead.dwNumOfNode,pNodePos);
	}

	nRetCode = pFile->Seek(RoadHead.dwPassageBlock, SEEK_SET);
	KGLOG_PROCESS_ERROR(nRetCode != -1);
	{
	
	list<KG3DRepresentObjectNode*>::iterator iNode = m_listNode.begin();
	
	float fLengthSum = 0;
	m_BBox.Clear();
	for (DWORD i = 0;i < RoadHead.dwNumOfPassage;i++)
	{
		KG3DTerrainRoadPassage* pPassage = new KG3DTerrainRoadPassage();
		if(pPassage)
		{
			_PassageData ReadData;
			if(SUCCEEDED(pPassage->ReadDataFromFile(pFile,ReadData)))
			{
				pPassage->CreateBuffersFromData(ReadData);
				pPassage->BulidPassageData(fLengthSum,m_fWidth,m_fBendModulus,m_nSegmentLength,m_fExtendWidth);
				m_listPassage.push_back(pPassage);
				m_BBox.AddPosition(pPassage->m_Bbox.A);
				m_BBox.AddPosition(pPassage->m_Bbox.B);
				m_ExtendBBox.AddPosition(pPassage->m_ExtendBBox.A);
				m_ExtendBBox.AddPosition(pPassage->m_ExtendBBox.B);

				if(iNode!=m_listNode.end())
				{
					pPassage->m_pNodeA = *iNode;
					++iNode;
					if(iNode!=m_listNode.end())
						pPassage->m_pNodeB = *iNode;
				}
			}
			else
			{
				SAFE_DELETE(pPassage);
			}
		}
		
	}
	this->m_fLength = fLengthSum;
	}
	hr = S_OK;
Exit0:
	KG_COM_RELEASE(pFile);
	SAFE_DELETE_ARRAY(pNodePos);
	return hr;
}