コード例 #1
0
//! 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);
}
コード例 #2
0
//! Adds a standard data block (type: view resource) to the chain of all data blocks.
//! Returns the total # of data blocks in the data block chain.
size_t U3DFileWriter::addStandardBlock_ViewResource(const mlU3D::ViewResource& viewResource)
{
    U3DDataBlockWriter ViewResourceBlock;
    ViewResourceBlock.blockType = mlU3D::BLOCKTYPE_VIEWRESOURCE;
    ViewResourceBlock.writeString(viewResource.resourceName);      // Write View Resource Name (9.8.2.1)
    ViewResourceBlock.writeU32(0x00000000);                        // Write Pass Count (9.8.2.2)

    return addDataBlock(ViewResourceBlock);
}
コード例 #3
0
//! Adds a standard data block (type: group node) to the chain of all data blocks.
//! Returns the total # of data blocks in the data block chain.
size_t U3DFileWriter::addStandardBlock_GroupNode(const std::string& groupNodeName, const std::string& parentNodeName)
{
    U3DDataBlockWriter GroupNodeBlock;
    GroupNodeBlock.blockType = mlU3D::BLOCKTYPE_GROUPNODE;

    GroupNodeBlock.writeString(groupNodeName);              // Write Group Node Name (9.5.1.1)
    _writeParentNodeData(GroupNodeBlock, parentNodeName);   // Write Parent Node Data (9.5.1.2) (Parent Node Name = empty --> = world)

    return addDataBlock(GroupNodeBlock);
}
コード例 #4
0
//! Adds a standard data block (type: light node) to the chain of all data blocks.
//! Returns the total # of data blocks in the data block chain.
size_t U3DFileWriter::addStandardBlock_LightNode(const std::string& lightNodeName, const std::string& lightResourceName)
{
    U3DDataBlockWriter LightNodeBlock;
    LightNodeBlock.blockType = mlU3D::BLOCKTYPE_LIGHTNODE;

    LightNodeBlock.writeString(lightNodeName);      // Write Light Node Name (9.5.3.1)
    _writeParentNodeData(LightNodeBlock, "");       // Write Parent Node Data (9.5.3.2) (Parent Node Name = empty --> = world)
    LightNodeBlock.writeString(lightResourceName);  // Write Light Resource Name (9.5.3.1) (Same as Light Node Name)

    return addDataBlock(LightNodeBlock);
}
コード例 #5
0
//! 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 mlU3D::ModelNode& modelNode)
{
    U3DDataBlockWriter ModelNodeBlock;
    ModelNodeBlock.blockType = mlU3D::BLOCKTYPE_MODELNODE;
    std::string parentName = mlU3D::U3DTools::getParentNameFromGroupPath(modelNode.groupPath);

    ModelNodeBlock.writeString(modelNode.internalName);            // Write Model Node Name (9.5.2.1)

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

    ModelNodeBlock.writeString(modelNode.geometryGeneratorName);   // Write Model Resource Name (9.5.2.3)
    ModelNodeBlock.writeU32(modelNode.visibility);                 // Write Model Visibility (9.5.2.4);

    return addDataBlock(ModelNodeBlock);
}
コード例 #6
0
//! 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);
}
コード例 #7
0
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;
}
コード例 #8
0
//! Adds a standard data block (type: light resource) to the chain of all data blocks.
//! Returns the total # of data blocks in the data block chain.
size_t U3DFileWriter::addStandardBlock_LightResource(const mlU3D::LightResource& lightResource)
{
    U3DDataBlockWriter LightResourceBlock;
    LightResourceBlock.blockType = mlU3D::BLOCKTYPE_LIGHTRESOURCE;
    LightResourceBlock.writeString(lightResource.resourceName);      // Write Light Resource Name (9.8.1.1)
    LightResourceBlock.writeU32(mlU3D::LIGHTRESOURCEATTRIBUTES_ALL); // Write Light Attributes (9.8.1.2)  [UNUSED BY ACROBAT]
    LightResourceBlock.writeU8(lightResource.lightType);             // Write Light Type (9.8.1.3)
    LightResourceBlock.writeF32(lightResource.lightColor[0]);        // Write Light Color - Red (9.8.1.4.1)
    LightResourceBlock.writeF32(lightResource.lightColor[1]);        // Write Light Color - Green (9.8.1.4.2)
    LightResourceBlock.writeF32(lightResource.lightColor[2]);        // Write Light Color - Blue (9.8.1.4.3)
    LightResourceBlock.writeF32(1.0f);                               // Write Light Color - Light Reserved Parameter (9.8.1.4.4) (shall be 1.0)
    LightResourceBlock.writeF32(lightResource.lightAttenuation[0]);  // Write Light Attenuation - Constant Factor (9.8.1.5.1)
    LightResourceBlock.writeF32(lightResource.lightAttenuation[1]);  // Write Light Attenuation - Linear Factor (9.8.1.5.2)
    LightResourceBlock.writeF32(lightResource.lightAttenuation[2]);  // Write Light Attenuation - Quadric Factor (9.8.1.5.3)
    LightResourceBlock.writeF32(lightResource.lightSpotAngle);       // Write Light Spot Angle (9.8.1.6)
    LightResourceBlock.writeF32(lightResource.lightIntensity);       // Write Light Intensity (9.8.1.7)

    return addDataBlock(LightResourceBlock);
}
コード例 #9
0
//! Adds a standard data block (type: Lit texture shader) to the chain of all data blocks.
//! Returns the total # of data blocks in the data block chain.
size_t U3DFileWriter::addStandardBlock_LitTextureShader(const mlU3D::LitTextureShader& shader)
{
    U3DDataBlockWriter LitTextureShaderBlock;
    LitTextureShaderBlock.blockType = mlU3D::BLOCKTYPE_LITTEXTURESHADER;
    LitTextureShaderBlock.writeString(shader.resourceName);                         // Write Lit Texture Shader Name (9.8.3.1)
    LitTextureShaderBlock.writeU32(mlU3D::LITTEXTURESHADERATTRIBUTES_ALL);          // Write Lit Texture Shader Attributes (9.8.3.2)  [UNUSED BY ACROBAT]
    LitTextureShaderBlock.writeF32(0.0f);                                           // Write Alpha Test Reference (9.8.3.3)           [UNUSED BY ACROBAT]
    LitTextureShaderBlock.writeU32(mlU3D::ALPHATESTFUCTION_ALWAYS);                 // Write Alpha Test Function (9.8.3.4)            [UNUSED BY ACROBAT]
    LitTextureShaderBlock.writeU32(mlU3D::COLORBLEND_ALPHABLEND);                   // Write Color Blend Function (9.8.3.5)           [UNUSED BY ACROBAT]
    LitTextureShaderBlock.writeU32(0x00000001);                                     // Write Render Pass Flags (9.8.3.6)              [UNUSED BY ACROBAT]
    LitTextureShaderBlock.writeU32(0x00000000);                                     // Write Shader Channels (9.8.3.7)
    LitTextureShaderBlock.writeU32(0x00000000);                                     // Write Alpha Texture Channels (9.8.3.8)         [UNUSED BY ACROBAT]
    LitTextureShaderBlock.writeString(shader.materialResourceName);                 // Write Material Name (9.8.3.9)
    // No texture information written since no Shader Channels are activated

    return addDataBlock(LitTextureShaderBlock);
}
コード例 #10
0
//! Adds a standard data block (type: view node) to the chain of all data blocks.
//! Returns the total # of data blocks in the data block chain.
size_t U3DFileWriter::addStandardBlock_ViewNode(const std::string& viewNodeName, const std::string& viewResourceName)
{
    U3DDataBlockWriter ViewNodeBlock;
    ViewNodeBlock.blockType = mlU3D::BLOCKTYPE_VIEWNODE;

    ViewNodeBlock.writeString(viewNodeName);                   // Write View Node Name (9.5.4.1)
    _writeParentNodeData(ViewNodeBlock, "");                   // Write Parent Node Data (9.5.4.2) (Parent Node Name = empty --> = world)
    ViewNodeBlock.writeString(viewResourceName);               // Write View Resource Name (9.5.4.3) (Same as View Node Name) [UNUSED BY ACROBAT]
    ViewNodeBlock.writeU32(mlU3D::VIEWNODEATTRIBUTE_DEFAULT);  // Write View Node Attributes (9.5.4.4)
    ViewNodeBlock.writeF32(0.0f);                              // Write View Near Clip (9.5.4.5.1)
    ViewNodeBlock.writeF32(0.0f);                              // Write View Far Clip (9.5.4.5.2)
    ViewNodeBlock.writeF32(0.0f);                              // Write View Projection (9.5.4.6.1)
    //ViewNodeBlock.writeF32(0.0f);                            // Write View Orthographic Height (9.5.4.6.2) (only for orthographic projection) [UNUSED BY ACROBAT]
    ViewNodeBlock.writeF32(100.0f);                            // Write View Port Width (9.5.4.7.1)
    ViewNodeBlock.writeF32(100.0f);                            // Write View Port Height (9.5.4.7.2)
    ViewNodeBlock.writeF32(50.0f);                             // Write View Port Horizontal Position (9.5.4.7.3)
    ViewNodeBlock.writeF32(50.0f);                             // Write View Port Vertical Position (9.5.4.7.4)
    ViewNodeBlock.writeU32(0x00000000);                        // Write Backdrop Count (9.5.4.8) [UNUSED BY ACROBAT]
    ViewNodeBlock.writeU32(0x00000000);                        // Write Overlay Count (9.5.4.10) [UNUSED BY ACROBAT]

    return addDataBlock(ViewNodeBlock);
}
コード例 #11
0
//! Adds a standard data block (type: shading modifier) to the chain of all data blocks.
//! Returns the total # of data blocks in the data block chain.
size_t U3DFileWriter::addStandardBlock_ShadingModifier(const std::string& shadingModifierName, const std::string& shaderName)
{
    U3DDataBlockWriter ShadingModifierBlock;
    ShadingModifierBlock.blockType = mlU3D::BLOCKTYPE_SHADINGMODIFIER;

    ShadingModifierBlock.writeString(shadingModifierName);                         // Write Shading Modifier Name (9.7.5.1)
    ShadingModifierBlock.writeU32(0x00000001);                                     // Write Chain Index (9.7.5.2)
    ShadingModifierBlock.writeU32(mlU3D::SHADINGMODIFIER_SHADINGATTRIBUTES_ALL);   // Write Shading Attributes (9.7.5.3)  (all = meshes, points, lines & glyphs) [UNUSED BY ACROBAT]
    ShadingModifierBlock.writeU32(0x00000001);                                     // Write Shader List Count (9.7.5.4)
    ShadingModifierBlock.writeU32(0x00000001);                                     // Write Shader Count (9.7.5.5)
    ShadingModifierBlock.writeString(shaderName);                                  // Write Shader Name (9.7.5.6)

    return addDataBlock(ShadingModifierBlock);
}
コード例 #12
0
//! Adds a standard data block (type: modifier chain) to the chain of all data blocks.
//! Returns the total # of data blocks in the data block chain.
size_t U3DFileWriter::addStandardBlock_ModifierChain(const std::string& modifierChainName,
        const MLuint32 modifierChainType,
        const MLuint32 modifierChainAttributes,
        const MLuint32 modifierCount)
{
    U3DDataBlockWriter ModifierChainBlock;
    ModifierChainBlock.blockType = mlU3D::BLOCKTYPE_MODIFIERCHAIN;

    ModifierChainBlock.writeString(modifierChainName);
    ModifierChainBlock.writeU32(modifierChainType);
    ModifierChainBlock.writeU32(modifierChainAttributes);
    ModifierChainBlock.writePaddingBytes(U3DDataBlockWriter::getNumPaddingBytes( 2 + (MLuint32)(modifierChainName.length()) ));
    ModifierChainBlock.writeU32(modifierCount);

    return addDataBlock(ModifierChainBlock);
}
コード例 #13
0
//! 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)
}
コード例 #14
0
//! 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;
}
コード例 #15
0
//! Adds a standard data block (type: CLOD mesh declaration) to the chain of all data blocks.
//! Returns the total # of data blocks in the data block chain.
size_t U3DFileWriter::addStandardBlock_CLODMeshDeclaration(const mlU3D::CLODMeshGenerator& meshGenerator)
{
    U3DDataBlockWriter CLODMeshDeclarationBlock;
    CLODMeshDeclarationBlock.blockType = mlU3D::BLOCKTYPE_CLODMESHDECLARATION;

    CLODMeshDeclarationBlock.writeString(meshGenerator.resourceName);     // Write Mesh Name (9.6.1.1.1)
    CLODMeshDeclarationBlock.writeU32(mlU3D::ReservedZero);               // Write Chain Index (9.6.1.1.2) (shall be zero)

    CLODMeshDeclarationBlock.writeU32(meshGenerator.meshAttributes);      // Write Max Mesh Description - Mesh Attributes (9.6.1.1.3.1)
    CLODMeshDeclarationBlock.writeU32(meshGenerator.faceCount);           // Write Max Mesh Description - Face Count (9.6.1.1.3.2) (# of faces)
    CLODMeshDeclarationBlock.writeU32(meshGenerator.vertexCount);         // Write Max Mesh Description - Position Count (9.6.1.1.3.3) (# of vertices)
    CLODMeshDeclarationBlock.writeU32(meshGenerator.normalCount);         // Write Max Mesh Description - Normal Count (9.6.1.1.3.4) (# of normals)
    CLODMeshDeclarationBlock.writeU32(meshGenerator.diffuseColorCount);   // Write Max Mesh Description - Diffuse Color Count (9.6.1.1.3.5)
    CLODMeshDeclarationBlock.writeU32(meshGenerator.specularColorCount);  // Write Max Mesh Description - Specular Color Count (9.6.1.1.3.6)
    CLODMeshDeclarationBlock.writeU32(0x00000001);                        // Write Max Mesh Description - Texture Coord Count (9.6.1.1.3.7)
    CLODMeshDeclarationBlock.writeU32(0x00000001);                        // Write Max Mesh Description - Shading Count (9.6.1.1.3.8) (shall be 1 since only one shader is supported by this version)
    CLODMeshDeclarationBlock.writeU32(meshGenerator.shadingAttributes);   // Write Max Mesh Description - Shading Description - Shading Attributes (9.6.1.1.3.9.1)
    CLODMeshDeclarationBlock.writeU32(0x00000000);                      // Write Max Mesh Description - Shading Description - Texture Layer Count (9.6.1.1.3.9.2) (shall be zero since textures are not supported by this version)
    //CLODMeshDeclarationBlock.writeU32(0x00000002);                    // Write Max Mesh Description - Shading Description - Texture Coord Dimensions (9.6.1.1.3.9.3)
    CLODMeshDeclarationBlock.writeU32(0x00000000);                      // Write Max Mesh Description - Shading Description - Original Shading ID (9.6.1.1.3.9.4)

    CLODMeshDeclarationBlock.writeU32(meshGenerator.vertexCount);       // Write CLOD Description - Minimum Resolution (9.6.1.1.4.1)  // Min resolution = max resolution -> base mesh only!
    //CLODMeshDeclarationBlock.writeU32(0);                                 // Write CLOD Description - Minimum Resolution (9.6.1.1.4.1)
    CLODMeshDeclarationBlock.writeU32(meshGenerator.vertexCount);       // Write CLOD Description - Final Maximum Resolution (9.6.1.1.4.2)

    CLODMeshDeclarationBlock.writeU32(0x000003E8);                        // Write Resource Description - Quality Factors - Position Quality Factor (9.6.1.1.5.1.1)
    CLODMeshDeclarationBlock.writeU32(0x000003E8);                        // Write Resource Description - Quality Factors - Normal Quality Factor (9.6.1.1.5.1.2)
    CLODMeshDeclarationBlock.writeU32(0x000003E8);                        // Write Resource Description - Quality Factors - Texture Coord Quality Factor (9.6.1.1.5.1.3)
    CLODMeshDeclarationBlock.writeF32(1.f/mlU3D::Quant_Position);         // Write Resource Description - Inverse Quantization - Position Inverse Quant (9.6.1.1.5.2.1)
    CLODMeshDeclarationBlock.writeF32(1.f/mlU3D::Quant_Normal);           // Write Resource Description - Inverse Quantization - Normal Inverse Quant (9.6.1.1.5.2.2)
    CLODMeshDeclarationBlock.writeF32(1.f/mlU3D::Quant_TextureCoord);     // Write Resource Description - Inverse Quantization - Texture Coord Inverse Quant (9.6.1.1.5.2.3)
    CLODMeshDeclarationBlock.writeF32(1.f/mlU3D::Quant_DiffuseColor);     // Write Resource Description - Inverse Quantization - Diffuse Color Inverse Quant (9.6.1.1.5.2.4)
    CLODMeshDeclarationBlock.writeF32(1.f/mlU3D::Quant_SpecularColor);    // Write Resource Description - Inverse Quantization - Specular Color Inverse Quant (9.6.1.1.5.2.5)
    CLODMeshDeclarationBlock.writeF32(0.9f);                              // Write Resource Description - Resource Parameters - Normal Crease Parameter (9.6.1.1.5.3.1)
    CLODMeshDeclarationBlock.writeF32(0.5f);                              // Write Resource Description - Resource Parameters - Normal Update Parameter (9.6.1.1.5.3.2)
    CLODMeshDeclarationBlock.writeF32(0.985f);                            // Write Resource Description - Resource Parameters - Normal Tolerance Parameter (9.6.1.1.5.3.3)

    CLODMeshDeclarationBlock.writeU32(0x00000000);                        // Write Skeleton Description - Bone Count (9.6.1.1.6.1) (shall be zero since skeltons are not supported by this version) [UNUSED BY ACROBAT]

    return addDataBlock(CLODMeshDeclarationBlock);
}
コード例 #16
0
//! Adds a standard data block (type: line set declaration) to the chain of all data blocks.
//! Returns the total # of data blocks in the data block chain.
size_t U3DFileWriter::addStandardBlock_LineSetDeclaration(const mlU3D::LineSetGenerator& lineSetGenerator)
{
    U3DDataBlockWriter LineSetDeclarationBlock;
    LineSetDeclarationBlock.blockType = mlU3D::BLOCKTYPE_LINESETDECLARATION;

    LineSetDeclarationBlock.writeString(lineSetGenerator.resourceName);     // Write Line Set Name (9.6.1.1.1)
    LineSetDeclarationBlock.writeU32(mlU3D::ReservedZero);                  // Write Chain Index (9.6.1.1.2) (shall be zero)

    LineSetDeclarationBlock.writeU32(mlU3D::ReservedZero);                  // Write Line Set Description - Line Set Reserved (9.6.3.1.3.1) (shall be zero)
    LineSetDeclarationBlock.writeU32(lineSetGenerator.lineCount);           // Write Line Set Description - Line Count (9.6.3.1.3.2) (# of lines)
    LineSetDeclarationBlock.writeU32(lineSetGenerator.pointCount);          // Write Line Set Description - Position Count (9.6.3.1.3.3) (# of positions - one point more than lines)
    LineSetDeclarationBlock.writeU32(lineSetGenerator.normalCount);         // Write Line Set Description - Normal Count (9.6.3.1.3.4) (# of normals)
    //LineSetDeclarationBlock.writeU32(lineSetGenerator.DiffuseColorCount);   // Write Line Set Description - Diffuse Color Count (9.6.3.1.3.5)
    LineSetDeclarationBlock.writeU32(0x00000000);                           // Write Line Set Description - Diffuse Color Count (9.6.3.1.3.5)
    //LineSetDeclarationBlock.writeU32(lineSetGenerator.specularColorCount);  // Write Line Set Description - Specular Color Count (9.6.3.1.3.6)
    LineSetDeclarationBlock.writeU32(0x00000000);                           // Write Line Set Description - Specular Color Count (9.6.3.1.3.6)
    //LineSetDeclarationBlock.writeU32(lineSetGenerator.textureCoordCount);   // Write Line Set Description - Texture Coord Count (9.6.3.1.3.7)
    LineSetDeclarationBlock.writeU32(0x00000000);                           // Write Line Set Description - Texture Coord Count (9.6.3.1.3.7)
    LineSetDeclarationBlock.writeU32(0x00000001);                           // Write Line Set Description - Shading Count (9.6.3.1.3.8)

    LineSetDeclarationBlock.writeU32(lineSetGenerator.shadingAttributes);   // Write Line Set Description - Shading Description - Shading Attributes (9.6.1.1.3.9.1)
    LineSetDeclarationBlock.writeU32(0x00000000);                           // Write Line Set Description - Shading Description - Texture Layer Count (9.6.1.1.3.9.2)
    //LineSetDeclarationBlock.writeU32(0x00000000);                           // Write Line Set Description - Shading Description - Texture Coord Dimensions (9.6.1.1.3.9.3) - only if Texture Layer Count > 0
    LineSetDeclarationBlock.writeU32(0x00000000);                           // Write Line Set Description - Shading Description - Original Shading ID (9.6.1.1.3.9.4)

    LineSetDeclarationBlock.writeU32(0x000003E8);                           // Write Resource Description - Quality Factors - Position Quality Factor (9.6.1.1.5.1.1)
    LineSetDeclarationBlock.writeU32(0x000003E8);                           // Write Resource Description - Quality Factors - Normal Quality Factor (9.6.1.1.5.1.2)
    LineSetDeclarationBlock.writeU32(0x000003E8);                           // Write Resource Description - Quality Factors - Texture Coord Quality Factor (9.6.1.1.5.1.3)
    LineSetDeclarationBlock.writeF32(1.f/mlU3D::Quant_Position);            // Write Resource Description - Inverse Quantization - Position Inverse Quant (9.6.1.1.5.2.1)
    LineSetDeclarationBlock.writeF32(1.f/mlU3D::Quant_Normal);              // Write Resource Description - Inverse Quantization - Normal Inverse Quant (9.6.1.1.5.2.2)
    LineSetDeclarationBlock.writeF32(1.f/mlU3D::Quant_TextureCoord);        // Write Resource Description - Inverse Quantization - Texture Coord Inverse Quant (9.6.1.1.5.2.3)
    LineSetDeclarationBlock.writeF32(1.f/mlU3D::Quant_DiffuseColor);        // Write Resource Description - Inverse Quantization - Diffuse Color Inverse Quant (9.6.1.1.5.2.4)
    LineSetDeclarationBlock.writeF32(1.f/mlU3D::Quant_SpecularColor);       // Write Resource Description - Inverse Quantization - Specular Color Inverse Quant (9.6.1.1.5.2.5)
    LineSetDeclarationBlock.writeU32(mlU3D::ReservedZero);                  // Write Resource Description - Resource Parameters - Reserved Line Set Parameter 1 (9.6.3.1.4.3.1) (shall be zero)
    LineSetDeclarationBlock.writeU32(mlU3D::ReservedZero);                  // Write Resource Description - Resource Parameters - Reserved Line Set Parameter 2 (9.6.3.1.4.3.2) (shall be zero)
    LineSetDeclarationBlock.writeU32(mlU3D::ReservedZero);                  // Write Resource Description - Resource Parameters - Reserved Line Set Parameter 3 (9.6.3.1.4.3.3) (shall be zero)

    LineSetDeclarationBlock.writeU32(0x00000000);                           // Write Skeleton Description - Bone Count (9.6.1.1.6.1) (shall be zero since skeltons are not supported by this version) [UNUSED BY ACROBAT]

    return addDataBlock(LineSetDeclarationBlock);
}
コード例 #17
0
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
    {
      float progressFldThisFaceValue = (progressIntervalForOneWEMPatch / meshGenerator.faceCount) * (thisFace + 1);
      float progressFldValue = progressStartForThisMesh + progressFldThisFaceValue;
      _progressFld->setFloatValue(progressFldValue);
    }

  }

  return thisCLODBaseMeshContinuationBlock;

}
コード例 #18
0
//! Adds a standard data block (type: material resource) to the chain of all data blocks.
//! Returns the total # of data blocks in the data block chain.
size_t U3DFileWriter::addStandardBlock_MaterialResource(const U3DObjectInfoStruct& objectInfo)
{
  U3DDataBlockWriter MaterialResourceBlock;
  MaterialResourceBlock.blockType = U3D_BLOCKTYPE_MATERIALRESOURCE;
  MaterialResourceBlock.writeString(objectInfo.MaterialName);                       // Write Material Resource Name (9.8.4.1)
  MaterialResourceBlock.writeU32(U3D_MATERIALRESOURCEATTRIBUTES_ALL);               // Write Material Attributes (9.8.4.2)     [UNUSED BY ACROBAT]
  MaterialResourceBlock.writeF32(objectInfo.AmbientColor[0]);                       // Ambient Color - Red (9.8.4.3.1)
  MaterialResourceBlock.writeF32(objectInfo.AmbientColor[1]);                       // Ambient Color - Green (9.8.4.3.2)
  MaterialResourceBlock.writeF32(objectInfo.AmbientColor[2]);                       // Ambient Color - Blue (9.8.4.3.3)
  MaterialResourceBlock.writeF32(objectInfo.DiffuseColor[0]);                       // Diffuse Color - Red (9.8.4.4.1)
  MaterialResourceBlock.writeF32(objectInfo.DiffuseColor[1]);                       // Diffuse Color - Green (9.8.4.4.2)
  MaterialResourceBlock.writeF32(objectInfo.DiffuseColor[2]);                       // Diffuse Color - Blue (9.8.4.4.3)
  MaterialResourceBlock.writeF32(objectInfo.SpecularColor[0]);                      // Specular Color - Red (9.8.4.5.1)
  MaterialResourceBlock.writeF32(objectInfo.SpecularColor[1]);                      // Specular Color - Green (9.8.4.5.2)
  MaterialResourceBlock.writeF32(objectInfo.SpecularColor[2]);                      // Specular Color - Blue (9.8.4.5.3)
  MaterialResourceBlock.writeF32(objectInfo.EmissiveColor[0]);                      // Emissive Color - Red (9.8.4.6.1)
  MaterialResourceBlock.writeF32(objectInfo.EmissiveColor[1]);                      // Emissive Color - Green (9.8.4.6.2)
  MaterialResourceBlock.writeF32(objectInfo.EmissiveColor[2]);                      // Emissive Color - Blue (9.8.4.6     

  MaterialResourceBlock.writeF32(0.5f);                                             // Write Reflectivity (9.8.4.7)
  MaterialResourceBlock.writeF32(objectInfo.DiffuseColor[3]);                       // Write Opacity (9.8.4.8)

  return addDataBlock(MaterialResourceBlock);
}
コード例 #19
0
//! Adds a standard data block (type: point set declaration) to the chain of all data blocks.
//! Returns the total # of data blocks in the data block chain.
size_t U3DFileWriter::addStandardBlock_PointSetDeclaration(const U3DPointSetInfoStruct& pointSetInfo)
{
  U3DDataBlockWriter PointSetDeclarationBlock;
  PointSetDeclarationBlock.blockType = U3D_BLOCKTYPE_POINTSETDECLARATION;

  PointSetDeclarationBlock.writeString(pointSetInfo.ResourceName);    // Write Point Set Name (9.6.2.1.1)
  PointSetDeclarationBlock.writeU32(U3D_ReservedZero);                // Write Chain Index (9.6.2.1.1) (shall be zero) 

  PointSetDeclarationBlock.writeU32(U3D_ReservedZero);                // Write Point Set Description - Point Set Reserved (9.6.2.1.3.1) (shall be zero)
  PointSetDeclarationBlock.writeU32(pointSetInfo.PointCount);         // Write Point Set Description - Point Count (9.6.2.1.3.2) (# of points)
  PointSetDeclarationBlock.writeU32(pointSetInfo.PointCount);         // Write Point Set Description - Position Count (9.6.2.1.3.3) (# of positions - equals # of points)
  PointSetDeclarationBlock.writeU32(pointSetInfo.NormalCount);        // Write Point Set Description - Normal Count (9.6.2.1.3.4) (# of normals)
  PointSetDeclarationBlock.writeU32(pointSetInfo.DiffuseColorCount);  // Write Point Set Description - Diffuse Color Count (9.6.2.1.3.5)
  PointSetDeclarationBlock.writeU32(pointSetInfo.SpecularColorCount); // Write Point Set Description - Specular Color Count (9.6.2.1.3.6)
  PointSetDeclarationBlock.writeU32(pointSetInfo.TextureCoordCount);  // Write Point Set Description - Texture Coord Count (9.6.2.1.3.7)
  PointSetDeclarationBlock.writeU32(0x00000001);                      // Write Point Set Description - Shading Count (9.6.2.1.3.8)

  PointSetDeclarationBlock.writeU32(pointSetInfo.ShadingAttributes);  // Write Point Set Description - Shading Description - Shading Attributes (9.6.1.1.3.9.1) 
  PointSetDeclarationBlock.writeU32(0x00000000);                      // Write Point Set Description - Shading Description - Texture Layer Count (9.6.1.1.3.9.2)
  //PointSetDeclarationBlock.writeU32(0x00000000);                      // Write Point Set Description - Shading Description - Texture Coord Dimensions (9.6.1.1.3.9.3) - only if Texture Layer Count > 0
  PointSetDeclarationBlock.writeU32(0x00000000);                      // Write Point Set Description - Shading Description - Original Shading ID (9.6.1.1.3.9.4)

  PointSetDeclarationBlock.writeU32(0x000003E8);                      // Write Resource Description - Quality Factors - Position Quality Factor (9.6.1.1.5.1.1)       [UNUSED BY ACROBAT]
  PointSetDeclarationBlock.writeU32(0x000003E8);                      // Write Resource Description - Quality Factors - Normal Quality Factor (9.6.1.1.5.1.2)         [UNUSED BY ACROBAT]
  PointSetDeclarationBlock.writeU32(0x000003E8);                      // Write Resource Description - Quality Factors - Texture Coord Quality Factor (9.6.1.1.5.1.3)  [UNUSED BY ACROBAT]
  PointSetDeclarationBlock.writeF32(1.f/U3DQuant_Position);           // Write Resource Description - Inverse Quantization - Position Inverse Quant (9.6.1.1.5.2.1)
  PointSetDeclarationBlock.writeF32(1.f/U3DQuant_Normal);             // Write Resource Description - Inverse Quantization - Normal Inverse Quant (9.6.1.1.5.2.2)
  PointSetDeclarationBlock.writeF32(1.f/U3DQuant_TextureCoord);       // Write Resource Description - Inverse Quantization - Texture Coord Inverse Quant (9.6.1.1.5.2.3)
  PointSetDeclarationBlock.writeF32(1.f/U3DQuant_DiffuseColor);       // Write Resource Description - Inverse Quantization - Diffuse Color Inverse Quant (9.6.1.1.5.2.4)
  PointSetDeclarationBlock.writeF32(1.f/U3DQuant_SpecularColor);      // Write Resource Description - Inverse Quantization - Specular Color Inverse Quant (9.6.1.1.5.2.5)
  PointSetDeclarationBlock.writeU32(U3D_ReservedZero);                // Write Resource Description - Resource Parameters - Reserved Point Set Parameter 1 (9.6.2.1.4.3.1) (shall be zero)
  PointSetDeclarationBlock.writeU32(U3D_ReservedZero);                // Write Resource Description - Resource Parameters - Reserved Point Set Parameter 2 (9.6.2.1.4.3.2) (shall be zero)
  PointSetDeclarationBlock.writeU32(U3D_ReservedZero);                // Write Resource Description - Resource Parameters - Reserved Point Set Parameter 3 (9.6.2.1.4.3.3) (shall be zero)

  PointSetDeclarationBlock.writeU32(0x00000000);                      // Write Skeleton Description - Bone Count (9.6.2.1.5) (shall be zero since skeltons are not supported by this version) [UNUSED BY ACROBAT]

  return addDataBlock(PointSetDeclarationBlock);
}
コード例 #20
0
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;
}
コード例 #21
0
//! Adds a standard data block (type: material resource) to the chain of all data blocks.
//! Returns the total # of data blocks in the data block chain.
size_t U3DFileWriter::addStandardBlock_MaterialResource(const mlU3D::MaterialResource& materialResource)
{
    U3DDataBlockWriter MaterialResourceBlock;
    MaterialResourceBlock.blockType = mlU3D::BLOCKTYPE_MATERIALRESOURCE;
    MaterialResourceBlock.writeString(materialResource.resourceName);                 // Write Material Resource Name (9.8.4.1)
    MaterialResourceBlock.writeU32(mlU3D::MATERIALRESOURCEATTRIBUTES_ALL);            // Write Material Attributes (9.8.4.2)     [UNUSED BY ACROBAT]
    MaterialResourceBlock.writeF32(materialResource.ambientColor[0]);                 // Ambient Color - Red (9.8.4.3.1)
    MaterialResourceBlock.writeF32(materialResource.ambientColor[1]);                 // Ambient Color - Green (9.8.4.3.2)
    MaterialResourceBlock.writeF32(materialResource.ambientColor[2]);                 // Ambient Color - Blue (9.8.4.3.3)
    MaterialResourceBlock.writeF32(materialResource.diffuseColor[0]);                 // Diffuse Color - Red (9.8.4.4.1)
    MaterialResourceBlock.writeF32(materialResource.diffuseColor[1]);                 // Diffuse Color - Green (9.8.4.4.2)
    MaterialResourceBlock.writeF32(materialResource.diffuseColor[2]);                 // Diffuse Color - Blue (9.8.4.4.3)
    MaterialResourceBlock.writeF32(materialResource.specularColor[0]);                // Specular Color - Red (9.8.4.5.1)
    MaterialResourceBlock.writeF32(materialResource.specularColor[1]);                // Specular Color - Green (9.8.4.5.2)
    MaterialResourceBlock.writeF32(materialResource.specularColor[2]);                // Specular Color - Blue (9.8.4.5.3)
    MaterialResourceBlock.writeF32(materialResource.emissiveColor[0]);                // Emissive Color - Red (9.8.4.6.1)
    MaterialResourceBlock.writeF32(materialResource.emissiveColor[1]);                // Emissive Color - Green (9.8.4.6.2)
    MaterialResourceBlock.writeF32(materialResource.emissiveColor[2]);                // Emissive Color - Blue (9.8.4.6

    MaterialResourceBlock.writeF32(materialResource.reflectivity);                    // Write Reflectivity (9.8.4.7)
    MaterialResourceBlock.writeF32(materialResource.diffuseColor[3]);                 // Write Opacity (9.8.4.8)

    return addDataBlock(MaterialResourceBlock);
}
コード例 #22
0
//! Adds a standard data block (type: material resource) to the chain of all data blocks.
//! Returns the total # of data blocks in the data block chain.
size_t U3DFileWriter::addStandardBlock_MaterialResourceWithDefaultLight(const std::string& materialResourceName)
{
    U3DDataBlockWriter MaterialResourceBlock;
    MaterialResourceBlock.blockType = mlU3D::BLOCKTYPE_MATERIALRESOURCE;
    MaterialResourceBlock.writeString(materialResourceName);                        // Write Material Resource Name (9.8.4.1)
    MaterialResourceBlock.writeU32(mlU3D::MATERIALRESOURCEATTRIBUTES_ALL);          // Write Material Attributes (9.8.4.2)

    MaterialResourceBlock.writeF32(1.0f);                                           // Ambient Color - Red (9.8.4.3.1)
    MaterialResourceBlock.writeF32(1.0f);                                           // Ambient Color - Green (9.8.4.3.2)
    MaterialResourceBlock.writeF32(1.0f);                                           // Ambient Color - Blue (9.8.4.3.3)
    MaterialResourceBlock.writeF32(0.65f);                                          // Diffuse Color - Red (9.8.4.4.1)
    MaterialResourceBlock.writeF32(0.65f);                                          // Diffuse Color - Green (9.8.4.4.2)
    MaterialResourceBlock.writeF32(0.65f);                                          // Diffuse Color - Blue (9.8.4.4.3)
    MaterialResourceBlock.writeF32(0.75f);                                          // Specular Color - Red (9.8.4.5.1)
    MaterialResourceBlock.writeF32(0.75f);                                          // Specular Color - Green (9.8.4.5.2)
    MaterialResourceBlock.writeF32(0.75f);                                          // Specular Color - Blue (9.8.4.5.3)
    MaterialResourceBlock.writeF32(0.0f);                                           // Emissive Color - Red (9.8.4.6.1)
    MaterialResourceBlock.writeF32(0.0f);                                           // Emissive Color - Green (9.8.4.6.2)
    MaterialResourceBlock.writeF32(0.0f);                                           // Emissive Color - Blue (9.8.4.6
    MaterialResourceBlock.writeF32(0.5f);                                           // Write Reflectivity (9.8.4.7)
    MaterialResourceBlock.writeF32(1.0f);                                           // Write Opacity (9.8.4.8)

    return addDataBlock(MaterialResourceBlock);
}
コード例 #23
0
U3DDataBlockWriter U3DSave::_createLineSetContinuationBlock(mlU3D::LineSetGenerator &lineSetGenerator) const
{
  MLuint8 signsXYZ;
  MLuint32 diffX;
  MLuint32 diffY;
  MLuint32 diffZ;

  _statusFld->setStringValue("Assembling data for LineSet: " + lineSetGenerator.resourceName + ".");

  U3DDataBlockWriter thisLineSetContinuationBlock;
  thisLineSetContinuationBlock.blockType = mlU3D::BLOCKTYPE_LINESETCONTINUATION;

  thisLineSetContinuationBlock.writeString(lineSetGenerator.resourceName);   // Write Line Set Name (9.6.3.2.1)
  thisLineSetContinuationBlock.writeU32(mlU3D::ReservedZero);                // Write Chain Index (9.6.3.2.2) (shall be zero) 
  thisLineSetContinuationBlock.writeU32(0x00000000);                         // Write Point Resolution Range - Start Resolution (9.6.3.2.3.1) 
  thisLineSetContinuationBlock.writeU32(lineSetGenerator.pointCount);        // Write Point Resolution Range - End Resolution (9.6.3.2.3.2) (# of points)

  for (MLuint32 currentPosition = 0; currentPosition < lineSetGenerator.pointCount; currentPosition++)
  {
    if (0 == currentPosition)
      // Special case for first position!
      // No split position and no diff - instead the position itself is written
    {
      mlU3D::PositionStruct startPosition = lineSetGenerator.positions[currentPosition];
      mlU3D::U3DTools::quantizePosition(startPosition.position, signsXYZ, diffX, diffY, diffZ);

      thisLineSetContinuationBlock.writeCompressedU32(mlU3D::Context_StaticFull + 1, 0);      // Write Line Description - Split Position Index (9.6.3.2.4.1) - for first entry with special value 0 and special context "r1" instead of "r0"
      thisLineSetContinuationBlock.writeCompressedU8(mlU3D::Context_cPosDiffSign, signsXYZ);  // Write Line Description - New Position Info - Position Difference Signs (9.6.1.3.4.10.1)
      thisLineSetContinuationBlock.writeCompressedU32(mlU3D::Context_cPosDiffX, diffX);       // Write Line Description - New Position Info - Position Difference X (9.6.1.3.4.10.2)
      thisLineSetContinuationBlock.writeCompressedU32(mlU3D::Context_cPosDiffY, diffY);       // Write Line Description - New Position Info - Position Difference Y (9.6.1.3.4.10.3)
      thisLineSetContinuationBlock.writeCompressedU32(mlU3D::Context_cPosDiffZ, diffZ);       // Write Line Description - New Position Info - Position Difference Z (9.6.1.3.4.10.4)

      thisLineSetContinuationBlock.writeCompressedU32(mlU3D::Context_cNormlCnt, 0);                    // Write Line Description - New Normal Count (9.6.3.2.4.3) 
      thisLineSetContinuationBlock.writeCompressedU32(mlU3D::Context_cPointCnt_cLineCnt_cFaceCnt, 0);  // Write Line Description - New Line Count (9.6.3.2.4.5)
    }
    else
    {
      MLuint32 splitPosition = currentPosition - 1;
      mlU3D::PositionStruct currentPositionData = lineSetGenerator.positions[currentPosition];
      mlU3D::PositionStruct predictedPositionData = lineSetGenerator.positions[splitPosition];
      Vector3 positionDifferenceVec3 = currentPositionData.position - predictedPositionData.position;
      mlU3D::U3DTools::quantizePosition(positionDifferenceVec3, signsXYZ, diffX, diffY, diffZ);

      thisLineSetContinuationBlock.writeCompressedU32(mlU3D::Context_StaticFull + currentPosition, splitPosition);  // Write Line Description - Split Position Index (9.6.3.2.4.1) 
      thisLineSetContinuationBlock.writeCompressedU8(mlU3D::Context_cPosDiffSign, signsXYZ);                        // Write Line Description - New Position Info - Position Difference Signs (9.6.1.3.4.10.1)
      thisLineSetContinuationBlock.writeCompressedU32(mlU3D::Context_cPosDiffX, diffX);                             // Write Line Description - New Position Info - Position Difference X (9.6.1.3.4.10.2)
      thisLineSetContinuationBlock.writeCompressedU32(mlU3D::Context_cPosDiffY, diffY);                             // Write Line Description - New Position Info - Position Difference Y (9.6.1.3.4.10.3)
      thisLineSetContinuationBlock.writeCompressedU32(mlU3D::Context_cPosDiffZ, diffZ);                             // Write Line Description - New Position Info - Position Difference Z (9.6.1.3.4.10.4)

      mlU3D::LinesVector newLines = mlU3D::U3DMarkerListTools::getNewLinesFromAllLines(lineSetGenerator.lines, currentPosition);
      MLuint32 newLineCount = (MLuint32)newLines.size();

      MLuint32 newNormalCount = (MLuint32)((lineSetGenerator.normalCount > 0) ? newLineCount : 0);                  // Should be zero -> no normals in this version
      thisLineSetContinuationBlock.writeCompressedU32(mlU3D::Context_cNormlCnt, newNormalCount * 2);                // Write Line Description - New Normal Count (9.6.2.2.4.3) - always 2 normals per line

      // Write New Normal Info (9.6.3.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
        thisLineSetContinuationBlock.writeCompressedU8(mlU3D::Context_cDiffNormalSign, signsXYZ);   // Write Normal Difference Signs (9.6.2.2.4.4.1)
        thisLineSetContinuationBlock.writeCompressedU32(mlU3D::Context_cDiffNormalX, diffX);        // Write Normal Difference X (9.6.2.2.4.4.2) 
        thisLineSetContinuationBlock.writeCompressedU32(mlU3D::Context_cDiffNormalY, diffY);        // Write Normal Difference Y (9.6.2.2.4.4.3)
        thisLineSetContinuationBlock.writeCompressedU32(mlU3D::Context_cDiffNormalZ, diffZ);        // Write Normal Difference Z (9.6.2.2.4.4.4) 

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

      thisLineSetContinuationBlock.writeCompressedU32(mlU3D::Context_cPointCnt_cLineCnt_cFaceCnt, newLineCount);  // Write Point Description - New Line Count (9.6.3.2.4.5) 

      // Write New Line Info (9.6.3.2.4.6)
      for (MLuint32 newLineInfoNumber = 0; newLineInfoNumber < newLineCount; newLineInfoNumber++)
      {
        MLuint32 startPosition = newLines[newLineInfoNumber].startIndex;
        thisLineSetContinuationBlock.writeCompressedU32(mlU3D::Context_cShading, 0x00000000);                         // Write Shading ID (9.6.3.2.4.6.1)
        thisLineSetContinuationBlock.writeCompressedU32(mlU3D::Context_StaticFull + currentPosition, startPosition);  // Write First Position Index (9.6.3.2.4.6.2) 

        for (MLuint32 j = 0; j<2; j++)
        {
          MLuint32 normalLocalIndex = ((newNormalCount > 0) ? 2 * newLineInfoNumber + j : 0);           // newLineNumber shall always be be 0, so normalLocalIndex is 0 or 1
          thisLineSetContinuationBlock.writeCompressedU32(mlU3D::Context_cNormlIdx, normalLocalIndex);  // Write Normal Local Index (9.6.3.2.4.6.3) [UNUSED BY ACROBAT]

          // Write no New Line Diffuse Color Coords (9.6.3.2.4.6.4) since it is not supported by this version
          // Write no New Line Specular Color Coords (9.6.3.2.4.6.5) since it is not supported by this version [UNUSED BY ACROBAT]
          // Write no New Line Texture Coords (9.6.3.2.4.6.6) since it is not supported by this version        [UNUSED BY ACROBAT]
        }
      }

    }  // if (0 == currentPosition)...

  }  // for (MLuint32 currentPosition...

  return thisLineSetContinuationBlock;
}