Skip to content

Bug: OgreImporter::ReadPass() should be more flexible #5232

Description

@stephengold

For some Ogre material files, the Assimp importer hangs, apparently due to inflexible parsing of colors in OgreImporter::ReadPass():

ss >> r >> g >> b;

To Reproduce
Steps to reproduce the behavior:

  1. Create an Ogre mesh that refers to a material:
<mesh>
	<submeshes>
		<submesh material="Oto" usesharedvertices="false">
			<faces count="1">
				<face v1="0" v2="1" v3="2"/>
			</faces>
			<geometry vertexcount="3">
				<vertexbuffer positions="true" normals="true" colours_diffuse="true" texture_coords="1">
					<vertex>
						<position x="0.131405" y="3.961532" z="0.030230"/>
						<normal x="0.154151" y="-0.988047" z="-0.000000"/>
						<colour_diffuse value="1.000000 1.000000 1.000000 1.000000"/>
						<texcoord u="0.267606" v="0.164020"/>
					</vertex>
					<vertex>
						<position x="-0.014431" y="3.953053" z="0.030230"/>
						<normal x="0.000000" y="-1.000000" z="-0.000000"/>
						<colour_diffuse value="1.000000 1.000000 1.000000 1.000000"/>
						<texcoord u="0.245920" v="0.164020"/>
					</vertex>
					<vertex>
						<position x="0.088690" y="3.961532" z="-0.072891"/>
						<normal x="0.109013" y="-0.988045" z="-0.109013"/>
						<colour_diffuse value="0.996078 0.996078 0.996078 0.996078"/>
						<texcoord u="0.261100" v="0.148840"/>
					</vertex>
				</vertexbuffer>
			</geometry>
		</submesh>
	</submeshes>
</mesh>
  1. Create the referenced Ogre material with a non-numeric value for the diffuse color:
material Oto
{
	technique
	{
		pass
		{
			diffuse vertexcolour
			specular 0.000000 0.000000 0.000000 0.250000
			texture_unit
			{
				texture Oto.jpg
			}
		}
	}
}
  1. Attempt to import the mesh into Assimp by invoking aiImportFile() .
  2. The application hangs because aiImportFile() never returns. Here is the debug output:
Info,  T0: Load Models/Oto/Oto.mesh.xml
Debug, T0: Assimp 5.2.0 amd64 gcc shared singlethreadedsingle : 
Info,  T0: Found a possible importer: Irrlicht Mesh Reader; trying signature-based detection
Info,  T0: Found a possible importer: Irrlicht Scene Reader; trying signature-based detection
Info,  T0: Found a possible importer: Collada Importer; trying signature-based detection
Info,  T0: Found a possible importer: Ogre3D Mesh Importer; trying signature-based detection
Debug, T0: Found positive match for header keyword: <mesh>
Info,  T0: Found a matching importer for this file format: Ogre3D Mesh Importer.
Info,  T0: Import root directory is 'Models/Oto/'
Debug, T0: Reading SubMesh 0
Debug, T0:   - Material: 'Oto'
Debug, T0:   - Uses shared geometry: false
Debug, T0:   - Faces 1
Debug, T0:   - Reading geometry of 3 vertices
Debug, T0:     - Contains positions
Debug, T0:     - Contains normals
Debug, T0:     - Contains 1 texture coords
Debug, T0: Reading Mesh
Debug, T0: Reading material 'Oto'
Debug, T0: material 'Oto'
Debug, T0:  technique ''
Debug, T0:   pass ''
Debug, T0:    diffuse 0 -nan -nan

Expected behavior
I encountered the above Ogre material in an old model I found on the web. Another import software I use accepts it as valid, an indication to apply vertex colors stored in the mesh. I haven't read the Ogre specs, so I'm unsure whether "vertexcolour" is a valid value for diffuse color.

  • If it's a valid value, I expect Assimp to handle it appropriately and return a valid scene.
  • If it's not valid, I expect Assimp to return NULL with a helpful message available via aiGetErrorString().

Screenshots
n/a

Platform (please complete the following information):

  • OS: Mint Linux (x86_64)
  • Browser: Firefox

Additional context
My test application is written in Java and uses the Assimp bindings included in LWJGL v3.3.2 .
According to the LWJGL release notes, that should be Assimp v5.2.5 but note that the debug output reports v5.2.0 !

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugGlobal flag to mark a deviation from expected behaviourOgreBugs related to the Ogre format

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions