//! 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); }
//! 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); }
//! 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); }
//! 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); }
//! 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); }
//! 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); }
//! 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); }
//! 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); }
//! 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); }
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; }