Exemplo n.º 1
0
void Nena::Utility::MayaReader::ImportShapes()
{
	::UINT32 result = 0;

	XMLNode *shapesNode = m_dataNode->first_node("Shapes"); if (shapesNode)
	{
		::UINT32 shapeCount; 
		GetCountAttribute(shapesNode, shapeCount, result); if (IsResultCheckedAt(result))
		{
			XMLNode *shapeNode = shapesNode->first_node("Shape");
			while (shapeNode)
			{
				ImportShape(shapeNode);
				shapeNode = shapeNode->next_sibling("Shape");
			}
		}
	}
}
Exemplo n.º 2
0
// Start the importer!
int AsciiImp::DoImport(const TCHAR *name,ImpInterface *ii,Interface *i, BOOL suppressPrompts) 
{
	int		status = 1;
	int		lastProgress = 0;
	int		progress;
	BOOL	fileValid = FALSE;

	mtlTab.ZeroCount();
	mtlTab.Shrink();

	// Grab the interface pointer.
	ip = i;
	impip = ii;
	
	// Prompt the user with our dialogbox.
	if (!DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_ASCIIIMPORT_DLG),
		ip->GetMAXHWnd(), ImportDlgProc, (LPARAM)this)) {
		return 1;
	}
	
	// Open the stream
	pStream = _tfopen(name,_T("rt"));
	if (!pStream) {
		return 0;
	}

	// Get the file size
	fseek(pStream, 0, SEEK_END);
	long fsize = ftell(pStream);
	fseek(pStream, 0, SEEK_SET);

	if(resetScene) {
		impip->NewScene();
	}

	TCHAR* token = NULL;

	
	token = GetToken();
	if (token) {
		if (Compare(token, ID_FILEID)) {
			fileVersion = (int)GetFloat();
			if (fileVersion >= 200 && fileVersion <= 200) {
				fileValid = TRUE;
			}
		}
	}

	if (!fileValid) {
		BadFile();
		fclose(pStream);
		return FALSE;
	}

#ifndef USE_IMPNODES
	ip->DisableSceneRedraw();
#endif

	// Startup the progress bar.
	ip->ProgressStart(_T("Importing file..."), TRUE, fn, NULL);

	long fpos = 0;
	while ((token = GetToken()) != NULL) {

		if (ip->GetCancel()) {
			status = 0;
			break;
		}

		// Update the progress meter
		// We will eliminate flicker by only calling this when it changes.
		fpos = ftell(pStream);
		progress = 100*fpos/fsize;
		if (progress != lastProgress) {
			ip->ProgressUpdate(progress);
		}
		lastProgress = progress;

		DebugPrint(_T("Token: %s\n"), token);

		if (Compare(token, ID_SCENE)) {
			ImportSceneParams();
		}
		else if (Compare(token, ID_MATERIAL_LIST)) {
			ImportMaterialList();
		}
		else if (Compare(token, ID_GEOMETRY)) {
			ImportGeomObject();
		}
		else if (Compare(token, ID_SHAPE)) {
			ImportShape();
		}
		else if (Compare(token, ID_HELPER)) {
			ImportHelper();
		}
		else if (Compare(token, ID_CAMERA)) {
			ImportCamera();
		}
		else if (Compare(token, ID_LIGHT)) {
			ImportLight();
		}
		else if (Compare(token, ID_COMMENT)) {
			GetToken();
		}
#ifndef USE_IMPNODES
		// ImpNodes doesn't support group creation!

		else if (Compare(token, ID_GROUP)) {
			groupMgr.BeginGroup(GetString());
			GetToken();		// BlockBegin
			GetToken();		// GroupDummy HelperObject
			GetToken();		// GroupDummy BlockBegin
			SkipBlock();	// GroupDummy
		}
		else if (Compare(token, _T("}"))) {
			groupMgr.EndGroup(ip);
		}
#endif
	}
	
	ip->ProgressEnd();

#ifndef USE_IMPNODES
	ip->EnableSceneRedraw();
#endif

	// Close the stream
	fclose(pStream);
	return status;
}