I am making a simple OpenGL 3.3 OBJ viewer in Python using the modules Pyglet and Ratcave. I want to load a textured sphere I made in Blender. While my Pyglet/Ratcave OBJ viewer loads untextured OBJ files, when I add textures to my project, I get this error and the program fails to load:
ValueError: could not convert string to float: 'textures'
What does this mean?
I got a different error when I tried to import textures from my OneDrive folder and use them in my Blender project. When I put the textures in the same folder as the script and OBJ/MTL files, it got rid of that error, but now I can't load the textures because, for whatever reason, Ratcave needs to convert the textures to a float and it can't do that.
import pyglet
import ratcave as rc
import time
window = pyglet.window.Window()
def update(dt):
pass
pyglet.clock.schedule(update)
# Insert filename into WavefrontReader
obj_filename = 'Textured Sphere Eevee.obj'
obj_reader = rc.WavefrontReader(obj_filename)
# Check which meshes can be found inside the Wavefront file, and extract it into a Mesh object for rendering
print(obj_reader.bodies.keys())
Sphere = obj_reader.get_mesh("Cube")
Sphere.position.xyz = 0, 0, -10
scene= rc.Scene(meshes=[Sphere])
@window.event
def on_draw():
with rc.default_shader:
scene.draw()
#scene.clear()
#time.sleep(10)
pyglet.app.run()
Traceback (most recent call last):
File "C:\Users\Jeffery\Desktop\Art\Pyglet Game Engine\scripts\Ratcave_OBJ_Loader_Test 2.py", line 15, in <module>
obj_reader = rc.WavefrontReader(obj_filename)
File "C:\Users\Jeffery\AppData\Local\Programs\Python\Python37-32\lib\site-packages\ratcave\wavefront.py", line 28, in __init__
self.bodies = read_wavefront(file_name)
File "C:\Users\Jeffery\AppData\Local\Programs\Python\Python37-32\lib\site-packages\wavefront_reader\reading.py", line 114, in read_wavefront
materials = read_mtlfile(path.join(path.dirname(fname_obj), fname_mtl))
File "C:\Users\Jeffery\AppData\Local\Programs\Python\Python37-32\lib\site-packages\wavefront_reader\reading.py", line 88, in read_mtlfile
material[prefix] = tuple(float(d) for d in split_data)
File "C:\Users\Jeffery\AppData\Local\Programs\Python\Python37-32\lib\site-packages\wavefront_reader\reading.py", line 88, in <genexpr>
material[prefix] = tuple(float(d) for d in split_data)
ValueError: could not convert string to float: 'textures'