Esempio n. 1
0
int RocketExporter::DoExport( const MCHAR *name,ExpInterface *ei,Interface *i, BOOL suppressPrompts/*=FALSE*/, DWORD options/*=0*/ )
{
	std::string fileName(name);
	std::transform(fileName.begin(), fileName.end(), fileName.begin(), std::tolower);

// 	if (options & SCENE_EXPORT_SELECTED)
// 	{
// 		GetExportOptions()->exportAll = false;
// 	}
// 	else
// 	{
// 		GetExportOptions()->exportAll = true;
// 	}
// 
// 	if (options & SCENE_EXPORT_VERTEX_COLOR)
// 	{
// 		GetExportOptions()->exportVertexColour = true;
// 	}
// 	else
// 	{
// 		GetExportOptions()->exportVertexColour = false;
// 	}
	GetExportOptions()->m_outFilePath = fileName;
	_enum.setTime(i->GetTime());
	_enum.addNode(i->GetRootNode());

// 	if (fileName.compare(fileName.size() - 3, 3, ".mz") == 0)
// 	{
// 		// Prompt the user with our dialogbox, and get all the options.
		if (!suppressPrompts)
		{
			if (!DialogBoxParam(gInstance, MAKEINTRESOURCE(IDD_DIALOG1), i->GetMAXHWnd(), ExportOptionsDlgProc, (LPARAM)this)) 
			{
				return 1;
			}
		}
// 
// 		_enum.read();
// 		_enum.write();
// 		GetExportOptions()->exportMode = eExportMode_MZ;
// 	}
// 	else if (fileName.compare(fileName.size() - 3, 3, ".fb") == 0)
	{
		GetExportOptions()->exportMode = eExportMode_FB;
		//_enum.readBone();
		if (_enum.read())
		{
			_enum.writeBone();
		}
	}
// 	else
// 	{
// 		MessageBox(NULL, "无法识别的导出文件后缀", "Error", MB_OK);
// 		return 1;
// 	}

	return 1;
}
Esempio n. 2
0
int PlatoExporter::DoExport( const MCHAR *name,ExpInterface *ei,Interface *i, BOOL suppressPrompts/*=FALSE*/, DWORD options/*=0*/ )
{
	std::string fileName(name);
	std::transform(fileName.begin(), fileName.end(), fileName.begin(), std::tolower);

	if (options & SCENE_EXPORT_SELECTED)
	{
		GetExportOptions()->exportAll = false;
	}
	else
	{
		GetExportOptions()->exportAll = true;
	}

	if (options & SCENE_EXPORT_VERTEX_COLOR)
	{
		GetExportOptions()->exportVertexColour = true;
	}
	else
	{
		GetExportOptions()->exportVertexColour = false;
	}

	if (options & SCENE_EXPORT_ANIMATION_ALL)
	{
		GetExportOptions()->exportAnims = true;
	}
	else
	{
		GetExportOptions()->exportAnims = false;
	}

	GetExportOptions()->m_outFilePath = fileName;
	_enum.setTime(i->GetTime());
	_enum.addNode(i->GetRootNode());

	{
		// Prompt the user with our dialogbox, and get all the options.
		if (!suppressPrompts)
		{
			if (!DialogBoxParam(gInstance, MAKEINTRESOURCE(IDD_DIALOG1), i->GetMAXHWnd(), ExportOptionsDlgProc, (LPARAM)this)) 
			{
				return 1;
			}
		}

		GetExportOptions()->exportMode = eExportMode_Terrain;
		if (_enum.read())
		{
			_enum.write();
		}
	}
	return 1;
}
HRESULT
CMayaManager::Scene_Export(
    const char* file,		// save file object
    const char* options,	// options string
    MPxFileTranslator::FileAccessMode mode)
{
    HRESULT hr = S_OK;
    MStatus stat = MS::kSuccess;
    CManagerLock SceneLock;
    MString mszAppDir;

    CStringA filename(file);
    const char* pExtension= strrchr(file, '.');
    if(!pExtension)
    {
        filename.Append( ".x");

        if(PathFileExistsA( filename.GetString() ))
        {
            CStringA Msg("Would you like to write over the existing file?\n");
            Msg.Append( filename );

            if( IDYES != MessageBoxA((HWND)M3dView::applicationShell(), Msg.GetString(), "File Exists", MB_YESNOCANCEL ) )
            {
                return S_OK;
            }
        }
    }
    else if(0 != _stricoll(".x", pExtension) )
    {
        MessageBoxA((HWND)M3dView::applicationShell(), "Cannot write over non- \".x\" file", "Incompatable File Type", 0 );
        return S_OK;
    }


    hr= GetExportOptions(false);
    if (DXCC_FAILED(hr))
        DXCC_GOTO_EXIT(e_Exit, FALSE);

    StringCchCopyA(ExportOpts.RelativeToPath, MAX_PATH, filename.GetString());
    for(LPSTR str= ExportOpts.RelativeToPath; str != NULL && *str != '\0'; str++)
    {
        if(str[0] == '/')
            str[0] = '\\';
    }
    PathRemoveFileSpecA(ExportOpts.RelativeToPath);




    if(false == TagGraph.GetCallbackState())
        MGlobal::executeCommand ("DXCCRebuildScene");
    else
        MGlobal::executeCommand ("DXCCRebuildDirty");





    SceneWriteLock(true, SceneLock);



    DXCC_DPF(TEXT("Maya XFile Exporter"));
    DXCC_DPF(TEXT("Copyright (C) 1998-2000 Microsoft Corporation. All Rights Reserved."));
    DXCC_DPFA("Exporting to \"%s\"...", filename.GetString());

    Scene_PrepareForExport(true, !ExportOpts.NoAnimation);

    hr= DXCCSaveScene(
            filename.GetString(),
            D3DXF_FILEFORMAT_TEXT,//D3DXF_FILEFORMAT_BINARY,//
            AccessManager(),
            AccessRoot(),
            NULL,
            &ExportOpts);
    if (DXCC_FAILED(hr))
        DXCC_GOTO_EXIT(e_Exit, TRUE);



e_Exit:

    SceneWriteUnlock(SceneLock);

    return hr;
}
Esempio n. 4
0
/********************************************************************************************

>	BOOL MakeBitmapFilter::DoCreateBitmap(Operation *pOp, Document *pDoc, KernelBitmap** ppBitmap)

	Author:		Will_Cowling (Xara Group Ltd) <*****@*****.**>
	Created:	11/6/96
	Purpose:	Exports the current selection as a bitmap, via the virtual fns of the
				inherited class.
	Returns:	TRUE if worked, FALSE if failed.
	SeeAlso:	GetExportOptions; PrepareToExport; ExportRenderNodes; CleanUpAfterExport;

********************************************************************************************/
BOOL MakeBitmapFilter::DoCreateBitmap(Operation *pOp, Document *pDoc, KernelBitmap** ppBitmap)
{
	ERROR3IF(ppBitmap == NULL, "NULL bitmap pointer passed to MakeBitmapFilter::DoCreateBitmap");
	if (ppBitmap == NULL)
		return FALSE;

	pTheBitmap = NULL;
	*ppBitmap = NULL;

	// Set the bitmap pointer to null just in case, usually only used by DoExportBitmap
	pExportBitmap = NULL;

	// Get pointer to the spread to export.
PORTNOTE("spread", "Multi-spread warning!")
	pSpread = GetFirstSpread(pDoc);

	// remember the document in the class variable
	TheDocument = pDoc;

	// We must now check if there is a selection present so that we can set up whether the
	// user gets the choice of exporting the selection, drawing or spread if there is a 
	// selection present OR just a choice between the spread or drawing if no selection is
	// present.
	// If have a caret selected in a text story then the selection will be almost zero so trap
	// this case as well. 
	RangeControl rg = GetApplication()->FindSelection()->GetRangeControlFlags();
	rg.PromoteToParent = TRUE;
	GetApplication()->FindSelection()->Range::SetRangeControl(rg);
	SelRange Rng(*(GetApplication()->FindSelection()));

	// now, run through the selection selecting all nodes under all compound nodes
	// if we don't do this then all compound nodes aren't rendered correctly with transparent
	// bitmaps
	Node * pNode = Rng.FindFirst(FALSE);

	while (pNode)
	{
		pNode->SetSelected(FALSE);
		pNode->SetSelected(TRUE);
		pNode = Rng.FindNext(pNode, FALSE);
	}

	rg.PromoteToParent = FALSE;
	GetApplication()->FindSelection()->Range::SetRangeControl(rg);
	GetApplication()->UpdateSelection();

	DocRect ClipRect = GetApplication()->FindSelection()->GetBoundingRect();
	SelectionType Selection = DRAWING;
 	if ( ClipRect.IsEmpty() || ClipRect.Width() < MinExportSize ||
		 ClipRect.Height() < MinExportSize)
		Selection = DRAWING;		// no selection present, so choose drawing by default
	else
		Selection = SELECTION;		// selection present, so choose this by default

	if (Selection != SELECTION)
	{
		BOOL UseDrawingBounds = TRUE;
		
		SelRange* pSel = GetApplication()->FindSelection();
		if (pSel && pSel->Count()==1)
		{
			// Only one thing selected ... Is it the Text Caret per chance ?
			Node* pSelNode = pSel->FindFirst();
			if (pSelNode && pSelNode->IsAVisibleTextNode())
			{
				VisibleTextNode* pTextNode = (VisibleTextNode*)pSelNode;
				if (pTextNode->IsACaret())
				{
				 	// Aha! It's the Caret that's selected.
					// We'll use the bounds of the parent text line instead then ...
					Node* pTextLine = pTextNode->FindParent();
					ERROR3IF(!IS_A(pTextLine, TextLine), "Caret doesn't have a parent text line in DoCreateBitmap");
					
					// Get the bounds of the text line
					ClipRect = ((TextLine*)pTextLine)->GetBoundingRect();				

					Selection = SELECTION;
					UseDrawingBounds = FALSE;
				}		 		
			}
		}

		if (UseDrawingBounds)
		{
			// Work out the size of the rectangle encompassing the drawing (visible layers only)
			ClipRect = GetSizeOfDrawing(pSpread);
		}
	}

	// Create somewhere to put the user options and fill them up
	MakeBitmapExportOptions* pMakeBmpExportOptions = (MakeBitmapExportOptions*)CreateExportOptions();
	if (pMakeBmpExportOptions == NULL)
	{
		Error::SetError(_R(IDS_OUT_OF_MEMORY));
		return FALSE;
	}

	pMakeBmpExportOptions->RetrieveDefaults();
	pMakeBmpExportOptions->SetDepth(32); // create bmp copies shoulda always default to being 32 bit
	pMakeBmpExportOptions->SetSelectionType(Selection);

	// Set the BaseBitmapFilter member so we can use base class functionality - blurghh
	SetExportOptions(pMakeBmpExportOptions);

	BOOL ok = GetExportOptions( (BitmapExportOptions*)pMakeBmpExportOptions );

	BOOL IsAnimation = BmapPrevDlg::m_pExportOptions == NULL;
	BaseBitmapFilter * pNewFilter = this;
	BitmapExportOptions * pExportOptions = BmapPrevDlg::m_pExportOptions;
	if (!IsAnimation)
	{
		pNewFilter = pExportOptions->FindBitmapFilterForTheseExportOptions();
		// from the exporting point of view we should always have been using png options
		// set them to the png options for the export part
		if (pNewFilter)
			pNewFilter->SetExportOptions(pExportOptions);
		// gets the real export options that the prevdlg has set up for us
		BmapPrevDlg::m_pExportOptions = NULL; // take responsibility for this data
	}
	else
	{
		// the animation export didn't bring up the dlg so never set BmapPrevDlg::m_pExportOptions
		// so continue with these options
		pExportOptions = (BitmapExportOptions*)pMakeBmpExportOptions;
	}

	SetExportOptions(pExportOptions);
	

	if (!ok)
	{
		SetExportOptions(NULL); // deletes the filter ptr and nulls it
		delete pExportOptions;
		return FALSE;									// if cancelled
	}


//////////////// SMFIX

	pExportOptions->MarkValid();
	SetDepthToRender(pExportOptions->GetDepth());

	// Set up device context and render region for this export.
	// This will show a progress hourglass for the objects being rendered
	// THis will now also write the data out to file via our ExportRenderNodes function
	if (!PrepareToExport(pSpread, pExportOptions->GetDepth(), pExportOptions->GetDPI(), 
							pExportOptions->GetSelectionType(), pExportOptions->GetDither()))
	{
		pNewFilter->SetExportOptions(NULL);
		SetExportOptions(NULL);
		delete pExportOptions;
		CleanUpAfterExport();
		return FALSE;
	}

	RenderInStrips = FALSE;
	
	if (!ExportRender(ExportRegion))
	{
		pNewFilter->SetExportOptions(NULL); // deletes the filter ptr and nulls it
		SetExportOptions(NULL);
		delete pExportOptions;
		CleanUpAfterExport();
		return FALSE;
	}

	// Now get the converted 32Bit BMP
	pTheBitmap = GetTheBitmap(pExportOptions);

	// if we`ve got a transparency index AND we`ve got a 32 Bit Render region with alpha channel info
	// then we can quickly do
	if(pExportOptions->GetDepth() <= 8 && pExportOptions->GetTransparencyIndex() != -1 && pTheBitmap)
	{
		// What we do now is to go throught the bitmap setting the relavent pixels to transparent
		// depending on the alpha channel info held in the 32 bit version.
		if(!ApplyTransparentColoursToBitmap(pTheBitmap,pExportOptions))
		{
			pNewFilter->SetExportOptions(NULL); // deletes the filter ptr and nulls it
			return FALSE;
		}

		// Now make sure the bitmap knows that it has a transparent colour!
		pTheBitmap->SetTransparencyIndex(pExportOptions->GetTransparencyIndex());
	}

	// Set pointer to the bitmap we have created
	*ppBitmap = pTheBitmap;

	pNewFilter->SetExportOptions(NULL); // deletes the filter ptr and nulls it
	SetExportOptions(NULL);
	delete pExportOptions;
	CleanUpAfterExport();

	return *ppBitmap != NULL;

//////////////// SMFIX
}