当前位置: 首页>>代码示例>>C++>>正文


C++ BinaryFile::Write方法代码示例

本文整理汇总了C++中BinaryFile::Write方法的典型用法代码示例。如果您正苦于以下问题:C++ BinaryFile::Write方法的具体用法?C++ BinaryFile::Write怎么用?C++ BinaryFile::Write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BinaryFile的用法示例。


在下文中一共展示了BinaryFile::Write方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ConvertToPyrosFormat

    bool AssimpModelImporter::ConvertToPyrosFormat(const std::string &Filename)
    {
        BinaryFile *bin = new BinaryFile();

        if (bin->Open(Filename.c_str(), 'w')) 
        {
        // Save Materials
        int32 materialsSize = materials.size();
        bin->Write(&materialsSize, sizeof(int32));
        for (std::vector<MaterialProperties>::iterator i=materials.begin();i!=materials.end();i++)
        {
            // Material ID
            bin->Write(&(*i).id,sizeof(int32));

            // Material Name
            int32 nameSize = (*i).Name.size();
            bin->Write(&nameSize,sizeof(int32));
            if (nameSize>0)
                bin->Write((*i).Name.c_str(),sizeof(char)*nameSize);

            // Color
            uchar Out = (uchar)(*i).haveColor;
            bin->Write(&Out, sizeof(uchar));

            bin->Write(&(*i).Color, sizeof(Vec4));

            // Specular
            Out = (uchar)(*i).haveSpecular;
            bin->Write(&Out, sizeof(uchar));

            bin->Write(&(*i).Specular, sizeof(Vec4));

            // Ambient
            Out = (uchar)(*i).haveAmbient;
            bin->Write(&Out, sizeof(uchar));

            bin->Write(&(*i).Ambient, sizeof(Vec4));

            // Emissive
            Out = (uchar)(*i).haveEmissive;
            bin->Write(&Out, sizeof(uchar));

            bin->Write(&(*i).Emissive, sizeof(Vec4));

            // WireFrame
            Out = (uchar)(*i).WireFrame;
            bin->Write(&Out, sizeof(uchar));

            // Twosided
            Out = (uchar)(*i).Twosided;
            bin->Write(&Out, sizeof(uchar));

            // Opacity
            bin->Write(&(*i).Opacity,sizeof(f32));

            // Shininess
            bin->Write(&(*i).Shininess,sizeof(f32));

            // Shininess Strength
            bin->Write(&(*i).ShininessStrength,sizeof(f32));

            // Textures
            // Color Map
            Out = (uchar)(*i).haveColorMap;
            bin->Write(&Out, sizeof(uchar));

            int32 colorMapSize = (*i).colorMap.size();
            bin->Write(&colorMapSize,sizeof(int32));
            if (colorMapSize>0)
                bin->Write((*i).colorMap.c_str(),sizeof(char)*colorMapSize);

            // Specular Map
            Out = (uchar)(*i).haveSpecularMap;
            bin->Write(&Out, sizeof(uchar));

            int32 specularMapSize = (*i).specularMap.size();
            bin->Write(&specularMapSize,sizeof(int32));
            if (specularMapSize>0)
                bin->Write((*i).specularMap.c_str(),sizeof(char)*specularMapSize);

            // Normal Map
            Out = (uchar)(*i).haveNormalMap;
            bin->Write(&Out, sizeof(uchar));
            
            int32 normalMapSize = (*i).normalMap.size();
            bin->Write(&normalMapSize,sizeof(int32));
            if (normalMapSize>0)
                bin->Write((*i).normalMap.c_str(),sizeof(char)*normalMapSize);

            // Have Bones
            Out = (uchar)(*i).haveBones;
            bin->Write(&Out, sizeof(uchar));
        }

        // Skeleton
        int32 skeletonSize = skeleton.size();
        bin->Write(&skeletonSize,sizeof(int32));
        if (skeletonSize>0)
        {
            // Write ids
//.........这里部分代码省略.........
开发者ID:Fuatnow,项目名称:Pyros3D,代码行数:101,代码来源:AssimpModelImporter.cpp


注:本文中的BinaryFile::Write方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。