• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ U3DDataBlockWriter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中U3DDataBlockWriter的典型用法代码示例。如果您正苦于以下问题:C++ U3DDataBlockWriter类的具体用法?C++ U3DDataBlockWriter怎么用?C++ U3DDataBlockWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: addDataBlock

//! Adds a standard data block (type: priority update) to the chain of all data blocks.
//! Returns the total # of data blocks in the data block chain.
size_t U3DFileWriter::addStandardBlock_PriorityUpdate(const MLuint32 newPriority)
{
    U3DDataBlockWriter PriorityUpdateBlock;
    PriorityUpdateBlock.blockType = mlU3D::BLOCKTYPE_PRIORITYUPDATE;
    PriorityUpdateBlock.writeU32(newPriority);

    return addDataBlock(PriorityUpdateBlock);
}
开发者ID:MeVisLab,项目名称:communitymodules,代码行数:10,代码来源:U3D_FileWriter.cpp


示例2: addDataBlock

//! Adds a standard data block (type: model node) to the chain of all data blocks.
//! Returns the total # of data blocks in the data block chain.
size_t U3DFileWriter::addStandardBlock_ModelNode(const U3DObjectInfoStruct& objectInfo)
{
  U3DDataBlockWriter ModelNodeBlock;
  ModelNodeBlock.blockType = U3D_BLOCKTYPE_MODELNODE;
  std::string parentName = getParentNameFromGroupPath(objectInfo.GroupPath);

  //ModelNodeBlock.writeString(objectInfo.DisplayName);        // Write Model Node Name (9.5.2.1) - Unfortunately, the model node name must be unique... :-(
  ModelNodeBlock.writeString(objectInfo.InternalName);       // Write Model Node Name (9.5.2.1)

  _writeParentNodeData(ModelNodeBlock, parentName);          // Write Parent Node Data (9.5.2.2)

  ModelNodeBlock.writeString(objectInfo.ResourceName);       // Write Model Resource Name (9.5.2.3) 
  ModelNodeBlock.writeU32(objectInfo.Visibility);            // Write Model Visibility (9.5.2.4);

  return addDataBlock(ModelNodeBlock);
}
开发者ID:hjkuijf,项目名称:communitymodules,代码行数:18,代码来源:U3D_FileWriter.cpp


示例3:

mlU3D::ColorMap U3DSave::_writeVertexColors(WEMPatch* patch, U3DDataBlockWriter& continuationBlock) const
{
  MLuint thisColorIndex = 0;
  mlU3D::ColorMap colorsMap;   // <Color,ColorIndex>

  const int numNodesInPatch = patch->getNumNodes();

  for (int n = 0; n < numNodesInPatch; n++)
  {
    WEMNode* thisNode = patch->getNodeAt(n);

    const Vector4 thisNodeColor = thisNode->getColor();

    mlU3D::ColorMap::iterator findIt = colorsMap.find(thisNodeColor);

    if (findIt == colorsMap.end())
    {
      // Color has not yet been added to map, so add it now
      colorsMap[thisNodeColor] = thisColorIndex;
      continuationBlock.writeF32Color(thisNodeColor);
      thisColorIndex++;
    }
    else
    {
      // Do nothing
    }

  }

  return colorsMap;
}
开发者ID:MeVisLab,项目名称:communitymodules,代码行数:31,代码来源:U3DSave_GeometryGenerators.cpp


示例4: Count

//! Write parent node data to the respective position of a (child) node block. (private)
void U3DFileWriter::_writeParentNodeData(U3DDataBlockWriter& dataBlock, const std::string& parentNodeName)
{
    dataBlock.writeU32(0x00000001);         // Write Parent Node Count (9.5.1.2.1)
    dataBlock.writeString(parentNodeName);  // Write empty Parent Node Name (9.5.1.2.2)
    dataBlock.writeIdentityMatrix();        // Write Parent Node Transform Matrix (9.5.1.2.3) (identity matrix)
}
开发者ID:MeVisLab,项目名称:communitymodules,代码行数:7,代码来源:U3D_FileWriter.cpp


示例5: memset

//! Write one block to file stream. (private)
bool U3DFileWriter::_writeBlockToFileStream(U3DDataBlockWriter& block, std::ofstream& ofstream)
{
    bool Success = false;

    MLuint32 flushBufferSize = block.getNumTotalBytes();

    mlU3D::DataBlockFundamental* flushBuffer = NULL;
    ML_CHECK_NEW(flushBuffer, mlU3D::DataBlockFundamental[flushBufferSize]);
    memset(flushBuffer, 0, flushBufferSize);

    if (NULL != flushBuffer)
    {
        // Add Block type, Data size & Meta data Size
        mlU3D::DataBlockFundamental flushBufferIndex = 0;
        flushBuffer[flushBufferIndex] = block.blockType;

        flushBufferIndex++;
        flushBuffer[flushBufferIndex] = block.getDataSizeWithChildDataBytes();

        flushBufferIndex++;
        flushBuffer[flushBufferIndex] = block.getMetaDataSizeWithoutPadding();

        flushBufferIndex++;


        // Add Data
        mlU3D::DataVector data = block.getData();
        for (mlU3D::DataBlockFundamental i = 0; i < block.getDataSize(); i++)
        {
            flushBuffer[flushBufferIndex] = data[i];
            flushBufferIndex++;
        }

        // Add Meta data
        mlU3D::DataVector metaData = block.getMetaData();
        for (mlU3D::DataBlockFundamental i = 0; i < block.getMetaDataSize(); i++)
        {
            flushBuffer[flushBufferIndex] = metaData[i];
            flushBufferIndex++;
        }
    }
    else
    {
        flushBufferSize = 0;
    }

    if ((0 != flushBufferSize) && (block.blockType != 0))
    {
        try
        {
            ofstream.write(reinterpret_cast<char*>(flushBuffer), flushBufferSize);
            ofstream.flush();
            Success = true;
        }
        catch (...)
        {
            // Ignore errors
        }
    }

    ML_DELETE_ARRAY(flushBuffer);

    return Success;
}
开发者ID:MeVisLab,项目名称:communitymodules,代码行数:65,代码来源:U3D_FileWriter.cpp


示例6: Name

U3DDataBlockWriter U3DSave::_createCLODBaseMeshContinuationBlock(WEMTrianglePatch* meshPatch, mlU3D::CLODMeshGenerator& meshGenerator) const
{
  mlU3D::ColorMap baseDiffuseColorsMap;

  float progressStart = 0.2f;
  float progressEnd = 0.9f;
  float progressRangeforAllMeshes = progressEnd - progressStart; // 0.7

  float progressIntervalForOneWEMPatch = progressRangeforAllMeshes / _inU3DObject->meshes.size();
  float progressStartForThisMesh = progressStart + progressIntervalForOneWEMPatch * meshGenerator.meshNumber;
  _progressFld->setFloatValue(progressStartForThisMesh);
  _statusFld->setStringValue("Assembling data for Mesh: " + meshGenerator.resourceName + ".");

  U3DDataBlockWriter thisCLODBaseMeshContinuationBlock;
  thisCLODBaseMeshContinuationBlock.blockType = mlU3D::BLOCKTYPE_CLODBASEMESHCONTINUATION;

  thisCLODBaseMeshContinuationBlock.writeString(meshGenerator.resourceName);       // Write Mesh Name (9.6.1.2.1)
  thisCLODBaseMeshContinuationBlock.writeU32(mlU3D::ReservedZero);               // Write Chain Index (9.6.1.2.2) (shall be zero) 
  thisCLODBaseMeshContinuationBlock.writeU32(meshGenerator.faceCount);            // Write Base Mesh Description - Face Count (9.6.1.2.3.1) (# of faces)
  thisCLODBaseMeshContinuationBlock.writeU32(meshGenerator.vertexCount);          // Write Base Mesh Description - Position Count (9.6.1.2.3.2) (# of vertices)
  thisCLODBaseMeshContinuationBlock.writeU32(meshGenerator.normalCount);          // Write Base Mesh Description - Normal Count (9.6.1.2.3.3) (# of normals)
  thisCLODBaseMeshContinuationBlock.writeU32(meshGenerator.diffuseColorCount);    // Write Base Mesh Description - Diffuse Color Count (9.6.1.2.3.4)
  thisCLODBaseMeshContinuationBlock.writeU32(meshGenerator.specularColorCount);   // Write Base Mesh Description - Specular Color Count (9.6.1.2.3.5)
  thisCLODBaseMeshContinuationBlock.writeU32(0x00000001);                    // Write Base Mesh Description - Texture Coord Count (9.6.1.2.3.6)

  // Write all vertex positions (in U3D, vertices are called "positions")        
  for (MLuint32 thisVertex = 0; thisVertex < meshGenerator.vertexCount; thisVertex++)
  {
    Vector3 wemPosition = meshPatch->getNodeAt(thisVertex)->getPosition();

    thisCLODBaseMeshContinuationBlock.writeF32(wemPosition[0]);             // Write Base Position - X (9.6.1.2.4.1.1)
    thisCLODBaseMeshContinuationBlock.writeF32(wemPosition[1]);             // Write Base Position - Y (9.6.1.2.4.1.2)
    thisCLODBaseMeshContinuationBlock.writeF32(wemPosition[2]);             // Write Base Position - Z (9.6.1.2.4.1.3)
  }

  for (MLuint32 thisNormal = 0; thisNormal < meshGenerator.normalCount; thisNormal++)
  {
    Vector3 nodeNormal = meshPatch->getNodeAt(thisNormal)->getNormal();

    thisCLODBaseMeshContinuationBlock.writeF32(nodeNormal[0]);              // Write Base Normal - X (9.6.1.2.4.2.1)
    thisCLODBaseMeshContinuationBlock.writeF32(nodeNormal[1]);              // Write Base Normal - Y (9.6.1.2.4.2.2)
    thisCLODBaseMeshContinuationBlock.writeF32(nodeNormal[2]);              // Write Base Normal - Z (9.6.1.2.4.2.3)
  }

  if (meshGenerator.diffuseColorCount > 0)
  {
    baseDiffuseColorsMap = _writeVertexColors(meshPatch, thisCLODBaseMeshContinuationBlock); // Write all Base Diffuse Colors (9.6.1.2.4.3)
  }

  for (MLuint32 thisSpecularColor = 0; thisSpecularColor < meshGenerator.specularColorCount; thisSpecularColor++)
  {
    thisCLODBaseMeshContinuationBlock.writeF32Color(_inU3DObject->defaultValues.defaultMaterialSpecularColor, 1.0f);   // Write Base Specular Color (9.6.1.2.4.4)
  }

  // Write Write Base Texture Coord (9.6.1.2.4.5)
  thisCLODBaseMeshContinuationBlock.writeF32(0.0f);       // Write Base Texture Coord U (9.6.1.2.4.5.1)
  thisCLODBaseMeshContinuationBlock.writeF32(0.0f);       // Write Base Texture Coord V (9.6.1.2.4.5.2)
  thisCLODBaseMeshContinuationBlock.writeF32(0.0f);       // Write Base Texture Coord S (9.6.1.2.4.5.3)
  thisCLODBaseMeshContinuationBlock.writeF32(0.0f);       // Write Base Texture Coord T (9.6.1.2.4.5.4)

  for (MLuint32 thisFace = 0; thisFace < meshGenerator.faceCount; thisFace++)
  {
    thisCLODBaseMeshContinuationBlock.writeCompressedU32(mlU3D::Context_cShading, 0);       // Write Shading ID (9.6.1.2.4.6.1)

    WEMFace* wemFace = meshPatch->getFaceAt(thisFace);

    for (MLuint thisNode = 0; thisNode < 3; thisNode++)
    {
      WEMNode* thisWEMNode = wemFace->getNodeAt(static_cast<unsigned int>(thisNode));
      const MLuint32 VertexIndex = thisWEMNode->getEntryNumber();
      const Vector4 thisWEMNodeColor = thisWEMNode->getColor();
      MLuint32 NormalIndex = VertexIndex;

      // Write Base Corner Info - Base Position Index (9.6.1.2.4.6.2.1)
      thisCLODBaseMeshContinuationBlock.writeCompressedU32(mlU3D::Context_StaticFull + meshGenerator.vertexCount, VertexIndex);

      // Write Base Corner Info - Base Normal Index (9.6.1.2.4.6.2.2)
      if (meshGenerator.normalCount > 0)
      {
        thisCLODBaseMeshContinuationBlock.writeCompressedU32(mlU3D::Context_StaticFull + meshGenerator.normalCount, NormalIndex);
      }

      // Write Base Corner Info - Base Diffuse Color Index (9.6.1.2.4.6.2.3)
      if (meshGenerator.diffuseColorCount > 0)
      {
        MLuint32 diffuseColorIndex = baseDiffuseColorsMap[thisWEMNodeColor];
        thisCLODBaseMeshContinuationBlock.writeCompressedU32(mlU3D::Context_StaticFull + meshGenerator.diffuseColorCount, diffuseColorIndex);
      }

      // Write Base Corner Info - Base Specular Color Index (9.6.1.2.4.6.2.4)
      if (meshGenerator.specularColorCount > 0)
      {
        thisCLODBaseMeshContinuationBlock.writeCompressedU32(mlU3D::Context_StaticFull + meshGenerator.specularColorCount, 0);
      }

      // Write Base Corner Info - Base Texture Coord Index (9.6.1.2.4.6.2.5)
      //thisCLODBaseMeshContinuationBlock.writeCompressedU32(U3D_StaticFull+1, 0);  // No texture layers
    }

    if (0 == (thisFace % 100))   // Set progress field every 100 faces to save GUI update cost
//.........这里部分代码省略.........
开发者ID:MeVisLab,项目名称:communitymodules,代码行数:101,代码来源:U3DSave_GeometryGenerators.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ UART类代码示例发布时间:2022-05-31
下一篇:
C++ U2SequenceObject类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap