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


C++ U3DDataBlockWriter::writeCompressedU8方法代码示例

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


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

示例1: Name

ML_START_NAMESPACE


//***********************************************************************************


U3DDataBlockWriter U3DSave::_createPointSetContinuationBlock(mlU3D::PointSetGenerator &pointSetGenerator) const
{
  MLuint8 signsXYZ;
  MLuint32 diffX;
  MLuint32 diffY;
  MLuint32 diffZ;

  _statusFld->setStringValue("Assembling data for PointSet: " + pointSetGenerator.resourceName + ".");

  U3DDataBlockWriter thisPointSetContinuationBlock;
  thisPointSetContinuationBlock.blockType = mlU3D::BLOCKTYPE_POINTSETCONTINUATION;

  thisPointSetContinuationBlock.writeString(pointSetGenerator.resourceName);    // Write Point Set Name (9.6.2.2.1)
  thisPointSetContinuationBlock.writeU32(mlU3D::ReservedZero);                  // Write Chain Index (9.6.2.2.2) (shall be zero) 
  thisPointSetContinuationBlock.writeU32(0x00000000);                           // Write Point Resolution Range - Start Resolution (9.6.2.2.3.1) 
  thisPointSetContinuationBlock.writeU32(pointSetGenerator.pointCount);         // Write Point Resolution Range - End Resolution (9.6.2.2.3.2) (# of points)

  for (MLuint32 currentPosition = 0; currentPosition < pointSetGenerator.pointCount; currentPosition++)
  {
    MLint32 splitPositionIndex = currentPosition - 1;

    if (0 == currentPosition)
      // Special case for first position!
      // No split position and no diff - instead the position itself is written
    {
      thisPointSetContinuationBlock.writeCompressedU32(mlU3D::Context_StaticFull + 0x00000001, 0);  // Write Split Position Index (9.6.2.2.4.1)
    }
    else
    {
      thisPointSetContinuationBlock.writeCompressedU32(mlU3D::Context_StaticFull + currentPosition, splitPositionIndex);  // Write Split Position Index (9.6.2.2.4.1)
    }

    // Write New Position Info (9.6.2.2.4.2)
    mlU3D::PositionStruct currentPositionData = pointSetGenerator.positions[currentPosition];
    mlU3D::PositionStruct predictedPositionData;
    if (splitPositionIndex >= 0) { predictedPositionData = pointSetGenerator.positions[splitPositionIndex]; }

    Vector3 positionDifferenceVec3 = currentPositionData.position - predictedPositionData.position;

    mlU3D::U3DTools::quantizePosition(positionDifferenceVec3, signsXYZ, diffX, diffY, diffZ);

    thisPointSetContinuationBlock.writeCompressedU8(mlU3D::Context_cPosDiffSign, signsXYZ);          // Write New Position Info - Position Difference Signs (9.6.1.3.4.10.1)
    thisPointSetContinuationBlock.writeCompressedU32(mlU3D::Context_cPosDiffX, diffX);               // Write New Position Info - Position Difference X (9.6.1.3.4.10.2)
    thisPointSetContinuationBlock.writeCompressedU32(mlU3D::Context_cPosDiffY, diffY);               // Write New Position Info - Position Difference Y (9.6.1.3.4.10.3)
    thisPointSetContinuationBlock.writeCompressedU32(mlU3D::Context_cPosDiffZ, diffZ);               // Write New Position Info - Position Difference Z (9.6.1.3.4.10.4)

    MLuint32 newPointCount = 1;  // Always add 1 new point in this version
    MLuint32 newNormalCount = ((pointSetGenerator.normalCount > 0) ? newPointCount : 0);             // Should be zero -> no normals in this version
    thisPointSetContinuationBlock.writeCompressedU32(mlU3D::Context_cNormlCnt, newNormalCount);      // Write Point Description - New Normal Count (9.6.2.2.4.3) - always 1 normal per point 

    // Write New Normal Info (9.6.2.2.4.4) [UNUSED BY ACROBAT]
    for (MLuint32 newNormalIndex = 0; newNormalIndex < newNormalCount; newNormalIndex++)
    {
      //Vector3 currentNormalVec3; currentNormalVec3.x = 0; currentNormalVec3.y = 0; currentNormalVec3.z = 0;
      //Vector3 predictedNormalVec3 = currentNormalVec3;  // Normals are always 0,0,0 in this version
      Vector3 normalDifferenceVec3;// = currentNormalVec3 - predictedNormalVec3;

      mlU3D::U3DTools::quantizeNormal(normalDifferenceVec3, signsXYZ, diffX, diffY, diffZ);

      // Write normal at line start
      thisPointSetContinuationBlock.writeCompressedU8(mlU3D::Context_cDiffNormalSign, signsXYZ);   // Write Normal Difference Signs (9.6.2.2.4.4.1)
      thisPointSetContinuationBlock.writeCompressedU32(mlU3D::Context_cDiffNormalX, diffX);        // Write Normal Difference X (9.6.2.2.4.4.2) 
      thisPointSetContinuationBlock.writeCompressedU32(mlU3D::Context_cDiffNormalY, diffY);        // Write Normal Difference Y (9.6.2.2.4.4.3)
      thisPointSetContinuationBlock.writeCompressedU32(mlU3D::Context_cDiffNormalZ, diffZ);        // Write Normal Difference Z (9.6.2.2.4.4.4) 
    }

    thisPointSetContinuationBlock.writeCompressedU32(mlU3D::Context_cPointCnt_cLineCnt_cFaceCnt, newPointCount);  // Write Point Description - New Point Count (9.6.2.2.4.5) 

    // Write New Point Info (9.6.2.2.4.6)
    for (MLuint32 newPointInfoNumber = 0; newPointInfoNumber < newPointCount; newPointInfoNumber++)
    {
      thisPointSetContinuationBlock.writeCompressedU32(mlU3D::Context_cShading, 0x00000000);                      // Write Shading ID (9.6.2.2.4.6.1)
      thisPointSetContinuationBlock.writeCompressedU32(mlU3D::Context_cNormlIdx, newPointInfoNumber);             // Write Normal Local Index (9.6.2.2.4.6.2) - Must be written although no normals are used at all in this version!

      // Write no New Point Diffuse Color Coords (9.6.2.2.4.6.3) since it is not supported by this version
      // Write no New Point Specular Color Coords (9.6.2.2.4.6.4) since it is not supported by this version [UNUSED BY ACROBAT]
      // Write no New Point Texture Coords (9.6.2.2.4.6.5) since it is not supported by this version        [UNUSED BY ACROBAT]
    }

  }  // for (MLuint32 currentPosition = 0...

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


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