Exemple #1
0
// Print a Node
void FBXParser::printNode(KFbxNode const & n){
  printTabs();
  const char * nodeName = n.GetName();

  fbxDouble3 tra = n.LclTranslation.Get();
  fbxDouble3 rot = n.LclRotation.Get();
  fbxDouble3 sca = n.LclScaling.Get();

  // Print node contents
  cout << "<node name = " << nodeName << "   ";
  cout << "translation = (" << tra[0] << ", " << tra[1] << ", " << tra[2] << ")" << "  ";
  cout << "rotation = (" << rot[0] << ", " << rot[1] << ", " << rot[2] << ")" << "  ";
  cout << "scaling = (" << sca[0] << ", " << sca[1] << ", " << sca[2] << ")" << endl;
  cout << "test 0" << endl;
  cout << "numTabs" << numTabs << endl;
  numTabs++;

  // Print node attributes
  for(int i=0; i < n.GetNodeAttributeCount(); i++){
    printAttribute(*n.GetNodeAttributeByIndex(i));
  }

  // Print children recursively
  for(int j = 0; j < n.GetChildCount(); j++){
    printNode(*n.GetChild(j));
  }

  numTabs--;
  printTabs();
  cout << "</node>" << endl;
}
Exemple #2
0
// Print Scene
void FBXParser::printScene(KFbxScene const &s){
  numTabs = 0;
  cout << "Printing scene..." << endl;
  KFbxNode * lRootNode = s.GetRootNode();

  if(lRootNode){
    for(int i=0; i < lRootNode->GetChildCount(); i++){
      printNode(*lRootNode->GetChild(i));
    }
  }
}
Exemple #3
0
void FBXParser::traverseElements(Assets & assets, KFbxNode const & n, string const & s) const{
  const KFbxNode * t;

  if(&n){
    for(int i=0; i < n.GetChildCount(); i++){
      t = n.GetChild(i);
      // Test node type
      if( t->GetNodeAttribute()->GetAttributeType() == KFbxNodeAttribute::eMESH ){
        cout << "   Storing mesh.... " << endl;
        storeMesh(*t, assets, s);
        storeTexture(*t, assets);
      }
    }
  }

}
int	FBXLoader::Import(char* name)
{
	KFbxSdkManager* manage;
	KFbxIOSettings*	ios;
	KFbxImporter*	import;
	KFbxScene*	scene;
	KFbxNode*	root;
	int		i;
	Node*		Father;
	Scene*		sceneM;

	sceneM = Scene::GetInstance();
	i = 0;
	manage = KFbxSdkManager::Create();
	ios = 	KFbxIOSettings::Create(manage, IOSROOT);
	manage->SetIOSettings(ios);
	import = KFbxImporter::Create(manage, "");
	if (!import->Initialize(name, -1, manage->GetIOSettings()))
	{
		printf("initialize failed\nerror is %s\n",import->GetLastErrorString());
		return (42);
	}
	scene = KFbxScene::Create(manage, "MY SCENE");
	import->Import(scene);
	import->Destroy();
	root = scene->GetRootNode();
	if (root)
	{
		this->Root = new Node();
		this->Root->SetFather(NULL);
		this->Root->SetName("root");
		while (i < root->GetChildCount()) //papa
		{
			Father = new Node();
			Root->AddChild(Father);
			this->PrintNode(root->GetChild(i), Father);
			++i;
		}
	}
	sceneM->AddRoot(this->Root);
	manage->Destroy();
	return (0);
}