def test_hasData(): # Simple test to see if the has whatever functions do their job correctly empty_mesh = MeshData() assert not empty_mesh.hasNormals() assert not empty_mesh.hasColors() assert not empty_mesh.hasUVCoordinates() assert not empty_mesh.hasIndices() filled_mesh = MeshData(normals=[], colors=[], uvs=[], indices=[]) assert filled_mesh.hasNormals() assert filled_mesh.hasColors() assert filled_mesh.hasUVCoordinates() assert filled_mesh.hasIndices()
def test_hasData(): # Simple test to see if the has whatever functions do their job correctly empty_mesh = MeshData() assert not empty_mesh.hasNormals() assert not empty_mesh.hasColors() assert not empty_mesh.hasUVCoordinates() assert not empty_mesh.hasIndices() filled_mesh = MeshData(normals = [], colors = [], uvs = [], indices=[]) assert filled_mesh.hasNormals() assert filled_mesh.hasColors() assert filled_mesh.hasUVCoordinates() assert filled_mesh.hasIndices()
def _setMeshAttributes(self, mesh: MeshData) -> None: self._shader.enableAttribute("a_vertex", "vector3f", 0) vertex_count = mesh.getVertexCount() offset = vertex_count * 3 * 4 if mesh.hasNormals(): self._shader.enableAttribute("a_normal", "vector3f", offset) offset += vertex_count * 3 * 4 if mesh.hasColors(): self._shader.enableAttribute("a_color", "vector4f", offset) offset += vertex_count * 4 * 4 if mesh.hasUVCoordinates(): self._shader.enableAttribute("a_uvs", "vector2f", offset) offset += vertex_count * 2 * 4 for attribute_name in mesh.attributeNames(): attribute = mesh.getAttribute(attribute_name) self._shader.enableAttribute(attribute["opengl_name"], attribute["opengl_type"], offset) if attribute["opengl_type"] == "vector2f": offset += mesh.getVertexCount() * 2 * 4 elif attribute["opengl_type"] == "vector4f": offset += mesh.getVertexCount() * 4 * 4 elif attribute["opengl_type"] == "int": offset += mesh.getVertexCount() * 4 elif attribute["opengl_type"] == "float": offset += mesh.getVertexCount() * 4 else: Logger.log( "e", "Attribute with name [%s] uses non implemented type [%s]." % (attribute["opengl_name"], attribute["opengl_type"])) self._shader.disableAttribute(attribute["opengl_name"])