/*
================
idSaveGame::WriteRenderEntity
================
*/
void idSaveGame::WriteRenderEntity( const renderEntity_t &renderEntity ) {
	int i;
	WriteModel( renderEntity.hModel );
	WriteInt( renderEntity.entityNum );
	WriteInt( renderEntity.bodyId );
	WriteBounds( renderEntity.bounds );
	// callback is set by class's Restore function
	WriteInt( renderEntity.suppressSurfaceInViewID );
	WriteInt( renderEntity.suppressShadowInViewID );
	WriteInt( renderEntity.suppressShadowInLightID );
	WriteInt( renderEntity.allowSurfaceInViewID );
	WriteVec3( renderEntity.origin );
	WriteMat3( renderEntity.axis );
	WriteMaterial( renderEntity.customShader );
	WriteMaterial( renderEntity.referenceShader );
	WriteSkin( renderEntity.customSkin );
	if( renderEntity.referenceSound != NULL ) {
		WriteInt( renderEntity.referenceSound->Index() );
	} else {
		WriteInt( 0 );
	}
	for( i = 0; i < MAX_ENTITY_SHADER_PARMS; i++ ) {
		WriteFloat( renderEntity.shaderParms[ i ] );
	}
	for( i = 0; i < MAX_RENDERENTITY_GUI; i++ ) {
		WriteUserInterface( renderEntity.gui[ i ], renderEntity.gui[ i ] ? renderEntity.gui[ i ]->IsUniqued() : false );
	}
	WriteFloat( renderEntity.modelDepthHack );
	WriteBool( renderEntity.noSelfShadow );
	WriteBool( renderEntity.noShadow );
	WriteBool( renderEntity.noDynamicInteractions );
	WriteBool( renderEntity.weaponDepthHack );
	WriteInt( renderEntity.forceUpdate );
}
Exemple #2
0
int DBMS::DropTable(string words) {
    string tableName = "";
    string::size_type i, j, k;
    i = words.find("drop table", 0);
    if (i != string::npos) {
        tableName = words.substr(11);
    }
    string c;
    string modelPath = this->GetWholeName(this->currentDb) + "\\model.md";
    ReadModel(modelPath, c);
    i = c.find("~" + tableName, 0);
    if (i != string::npos) {
        j = c.find("~", i + 1);
        if (j != string::npos) {
            c.erase(i, j - i);
        } else {
            c.erase(i);
        }
        WriteModel(c, 0);

        tableName = GetWholeName(currentDb + "\\" + tableName + ".tab");
        tableName.insert(0, "del ");
        system(tableName.c_str());

        return 0;
    } 
    else return -1;

}
recondite::Model* reProjectAssets::ImportModel(const wxString& path) {
	import::ModelImporter modelImporter;
	import::ModelImporterOptions options;
	ModelData modelData;

	int error = modelImporter.ImportModel(path.c_str().AsChar(), modelData, options);

	if (!error) {
		modelData.CalculateBoundings();

		wxFileName modelPath(path);
		wxString modelName = modelPath.GetName();
		WriteModel(modelData, modelName);

		if (modelData.GetLineMeshCount() == 0) {
			CreateSelectionWireframeForModel(modelData);
		}

		recondite::Model* model = _component->GetEngine()->content->Models()->LoadFromData(modelData, modelName.c_str().AsChar());

		wxString modelHandle = GetAssetPath(rAssetType::Model, modelName);
		_manifest.Add(rAssetType::Model, modelName.c_str().AsChar(), modelHandle.c_str().AsChar());

		return model;
	}

	return nullptr;
}
bool TransitionModel::WriteModel(std::string model_path, HMMErrorType &status) {
  FILE* fout = fopen(model_path.c_str(), "w");
  if (!fout) {
    status = kObservationErrorFileOpenFail;
    return false;
  }
  return WriteModel(fout, status);
}
Exemple #5
0
bool CModelFile::WriteModel(const std::string& fileName)
{
    std::ofstream stream;
    stream.open(fileName.c_str(), std::ios_base::out | std::ios_base::binary);
    if (!stream.good())
    {
        GetLogger()->Error("Could not open file '%s'\n", fileName.c_str());
        return false;
    }

    return WriteModel(stream);
}
HRESULT CXMLExporterBase::DoExport(BSTR filename, ISkpDocument* activeDocument,
                                   SketchUpPluginProgressCallback* callback)
{
    printf("File: %s\n", (const char *)((_bstr_t)filename));
    _bstr_t bFileName(filename, true);

    m_pDocument = activeDocument;
    m_pProgressBar = callback;

    if( m_pDocument==NULL )
    {
        printf("The document interface is not set\n");
        return E_FAIL;
    }

    if( !OpenFile(filename) )
    {
        printf("Cannot open file: %s\n", (const char*)bFileName);
        return E_FAIL;
    }

    m_fileName = (const char*)bFileName;
    printf("Filename %s\n", m_fileName.c_str());
    
    // Write the beginning of the block
    Write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n");

    HRESULT hr;
    try
    {
        hr = WriteModel();
    }
    catch(HRESULT hres)
    {
        hr = hres;
    }

    CloseFile();
    
    return hr;
}
        void TensorBoardFileWriter::Init()
        {
            time_t time = std::time(0);
            std::wstring filePath = GetNewFilePath(m_dir, time);

            msra::files::make_intermediate_dirs(filePath);

            m_file = fopenOrDie(ToString(filePath), "wb");
            m_fileName = filePath;

            // Write the first record with the current version, and flush
            // right away so the file contents will be easily determined.
            WriteVersion(time);

            if (m_model)
            {
                WriteModel();
            }

            Flush();
        }
Exemple #8
0
void WriteFile (void)
{
	FILE		*modelouthandle;
	int			total = 0;
	int			i;

	pStart = kalloc( 1, FILEBUFFER );

	StripExtension (outname);

	for (i = 1; i < numseqgroups; i++)
	{
		// write the non-default sequence group data to separate files
		char groupname[128], localname[128];

		sprintf( groupname, "%s%02d.mdl", outname, i );

		printf ("writing %s:\n", groupname);
		modelouthandle = SafeOpenWrite (groupname);

		pseqhdr = (studioseqhdr_t *)pStart;
		pseqhdr->id = IDSTUDIOSEQHEADER;
		pseqhdr->version = STUDIO_VERSION;

		pData = pStart + sizeof( studioseqhdr_t ); 

		pData = WriteAnimations( pData, pStart, i );

		ExtractFileBase( groupname, localname );
		sprintf( sequencegroup[i].name, "models\\%s.mdl", localname );
		strcpy( pseqhdr->name, sequencegroup[i].name );
		pseqhdr->length = pData - pStart;

		printf("total     %6d\n", pseqhdr->length );

		SafeWrite( modelouthandle, pStart, pseqhdr->length );

		fclose (modelouthandle);
		memset( pStart, 0, pseqhdr->length );
	}

	if (split_textures)
	{
		// write textures out to a separate file
		char texname[128];

		sprintf( texname, "%sT.mdl", outname );

		printf ("writing %s:\n", texname);
		modelouthandle = SafeOpenWrite (texname);

		phdr = (studiohdr_t *)pStart;
		phdr->id = IDSTUDIOHEADER;
		phdr->version = STUDIO_VERSION;

		pData = (byte *)phdr + sizeof( studiohdr_t );

		WriteTextures( );

		phdr->length = pData - pStart;
		printf("textures  %6d bytes\n", phdr->length );

		SafeWrite( modelouthandle, pStart, phdr->length );

		fclose (modelouthandle);
		memset( pStart, 0, phdr->length );
		pData = pStart;
	}

//
// write the model output file
//
	strcat (outname, ".mdl");
	
	printf ("---------------------\n");
	printf ("writing %s:\n", outname);
	modelouthandle = SafeOpenWrite (outname);

	phdr = (studiohdr_t *)pStart;

	phdr->id = IDSTUDIOHEADER;
	phdr->version = STUDIO_VERSION;
	strcpy( phdr->name, outname );
	VectorCopy( eyeposition, phdr->eyeposition );
	VectorCopy( bbox[0], phdr->min ); 
	VectorCopy( bbox[1], phdr->max ); 
	VectorCopy( cbox[0], phdr->bbmin ); 
	VectorCopy( cbox[1], phdr->bbmax ); 

	phdr->flags = gflags;

	pData = (byte *)phdr + sizeof( studiohdr_t );

	WriteBoneInfo( );
	printf("bones     %6d bytes (%d)\n", pData - pStart - total, numbones );
	total = pData - pStart;

	pData = WriteAnimations( pData, pStart, 0 );

	WriteSequenceInfo( );
	printf("sequences %6d bytes (%d frames) [%d:%02d]\n", pData - pStart - total, totalframes, (int)totalseconds / 60, (int)totalseconds % 60 );
	total  = pData - pStart;

	WriteModel( );
	printf("models    %6d bytes\n", pData - pStart - total );
	total  = pData - pStart;

	if (!split_textures)
	{
		WriteTextures( );
		printf("textures  %6d bytes\n", pData - pStart - total );
	}

	phdr->length = pData - pStart;

	printf("total     %6d\n", phdr->length );

	SafeWrite( modelouthandle, pStart, phdr->length );

	fclose (modelouthandle);
}
Exemple #9
0
int DBMS::CreateTable(string sentence) {
    const string primaryKey = "primary key";
    const char star = '*';
    int res = 0;
    string modelPath = this->GetWholeName(this->currentDb) + "\\model.md";
    string tableName = "";
    string::size_type i, j, k;
    sentence = sentence.erase(0, 12);
    i = sentence.find(' ', 0);
    if (i != string::npos) {
        i++;
        j = sentence.find('(', i);
        if (j != string::npos) {
            tableName = sentence.substr(i, j - i);
        }
    }
    if (tableName.length() == 0)
        return -1;

    string c;
    ReadModel(modelPath, c);
    i = c.find("~" + tableName, 0);
    if (i != string::npos) {
        res = TABLEEXISTED;
        return res;
    }
    /*  查找关键字primary key 然后替换为星号*  */
    i = 0;
    while (true) {
        i = sentence.find(primaryKey, 0);
        if (i != string::npos) {
            sentence.replace(i, primaryKey.length(), 1, star);
        } else {
            break;
        }
    }
    /*  查找关键字char 然后替换为0  */
    i = 0;
    while (true) {
        i = sentence.find(" char", 0);
        if (i != string::npos) {
            j = sentence.find(')', i);
            if (j != string::npos) {
                k = sentence.find('*', j);
                if (k - j > 5 || k == string::npos) {
                    sentence.insert(j, " # ");
                }
            }
            sentence.replace(i, 5, " 0 ");
        } else {
            break;
        }
    }
    /*  查找关键字int 然后替换为1 */
    i = 0;
    while (true) {
        i = sentence.find(" int", 0);
        if (i != string::npos) {

            k = sentence.find('*', i + 3);
            if (k - i > 5 || k == string::npos) {
                sentence.insert(i + 4, " #");
            }


            sentence.replace(i, 5, " 1 ");
        } else {
            break;
        }
    }
    sentence = Parse(sentence);
    sentence.insert(0, 1, '~');

    WriteModel(sentence, 1);

    /*  创建tab文件供元组信息存放  */
    string tableFile;
    fstream fileIO;
    tableFile = GetWholeName(currentDb);
    tableFile += "\\";
    tableFile.append(tableName);
    tableFile += ".tab";
    fileIO.open(tableFile.c_str(), ios::binary | ios::out);
    fileIO.close();

    res = 0;

    return res;


}
int Unreal3DExport::DoExport( const TCHAR *name, ExpInterface *ei, Interface *i, BOOL suppressPrompts, DWORD options )
{
    int Result = FALSE;

    // Set a global prompt display switch
    bShowPrompts = suppressPrompts ? false : true;
    bExportSelected = (options & SCENE_EXPORT_SELECTED) ? true : false;
    
    // Get file names
    SplitFilename(TSTR(name), &FilePath, &FileName, &FileExt);

    if( MatchPattern(FileName,TSTR(_T("*_d")),TRUE)
    ||  MatchPattern(FileName,TSTR(_T("*_a")),TRUE) )
    {
        FileName = FileName.Substr(0,FileName.length()-2);
    }

    ModelFileName = FilePath + _T("\\") + FileName + TSTR(_T("_d")) + FileExt;
    AnimFileName = FilePath + _T("\\") + FileName + TSTR(_T("_a")) + FileExt;
    ScriptFileName = FilePath + _T("\\") + FileName + TSTR(_T("_rc.uc"));


    // Open Log
    fLog = _tfopen(FilePath + _T("\\") + FileName + _T(".log") ,_T("wb"));

    // Init
    pInt = GetCOREInterface();
    pInt->ProgressStart( GetString(IDS_INFO_INIT), TRUE, fn, this);
    Progress += U3D_PROGRESS_INIT;

    try 
    {
        MyErrorProc pErrorProc;
        SetErrorCallBack(&pErrorProc);

        ReadConfig();


        //if(bShowPrompts)
        /*DialogBoxParam(hInstance, 
                MAKEINTRESOURCE(IDD_PANEL), 
                GetActiveWindow(), 
                Unreal3DExportOptionsDlgProc, (LPARAM)this);*/

	    //if(showPrompts) 
	    {
		    // Prompt the user with our dialogbox, and get all the options.
		    if(!DialogBoxParam(hInstance, 
				MAKEINTRESOURCE(IDD_PANEL), 
				GetActiveWindow(), 
				Unreal3DExportOptionsDlgProc, (LPARAM)this)) 
            {
			    throw CancelException();
		    }
	    }

        // Enumerate interesting nodes
        Init();

        // Fetch data from nodes
        GetTris();
        GetAnim();

        // Prepare data for writing
        Prepare();     

        // Write to files
        WriteScript();
        WriteModel();   
        WriteTracking();

        // Show optional summary
        ShowSummary();

        WriteConfig();

        Result = IMPEXP_SUCCESS;
    }
    catch( CancelException& )
    {
        Result = IMPEXP_CANCEL;
    }
    catch( MAXException& e )
    {
        if( bShowPrompts && !e.message.isNull() )
        {
            MaxMsgBox(pInt->GetMAXHWnd(),e.message,ShortDesc(),MB_OK|MB_ICONERROR);
        }

        Result = IMPEXP_FAIL;
    }

    // Release scene
    if( pScene != NULL )
    {
        pScene->ReleaseIGame();
        pScene = NULL;
    }

    // Close files
    fclosen(fMesh);
    fclosen(fAnim);
    fclosen(fLog);
    fclosen(fScript);
    
    // Return to MAX
    pInt->ProgressEnd();  
    return Result;
}