Loading Obj Files in Soya3d engine

Posted by John Riselvato on Game Development See other posts from Game Development or by John Riselvato
Published on 2011-02-03T22:59:09Z Indexed on 2011/02/03 23:35 UTC
Read the original article Hit count: 484

Filed under:
|

I recently just found soya3d and from what i have seen through the tutorials i will be able to make exactly what i wanted with python skills.

Now i have built this map generator. The only issue is that i can not manage to understand from any documents how to load obj files. At first i figured that i had to convert it to a .data file, but i dont understand how to do this. I just want to load a simple model of a house. I tried using the soya_editor, but i can not figure out at all how to do anything with that. Heres my script so far:

import sys, os, os.path, soya, soya.sdlconst
width, height = 760, 375
soya.init("Generator 0.1", width, height)
soya.path.append(os.path.join(os.path.dirname(sys.argv[0]), "data"))

scene = soya.World()
model = soya.model.get("house")

light = soya.Light(scene)
light.set_xyz(0.5, 0.0, 2.0)

camera = soya.Camera(scene)
camera.z = 2.0

soya.set_root_widget(camera)
soya.MainLoop(scene).main_loop()

house is in .obj form at folder data/models The error i get is:

Traceback (most recent call last):
  File "introduction.py", line 7, in <module>
    model = soya.Model.get("house")
  File "/usr/lib/pymodules/python2.6/soya/__init__.py", line 259, in get
    return klass._alls.get(filename) or klass._alls.setdefault(filename, klass.load(filename))
  File "/usr/lib/pymodules/python2.6/soya/__init__.py", line 268, in load
    dirname  = klass._get_directory_for_loading_and_check_export(filename)
  File "/usr/lib/pymodules/python2.6/soya/__init__.py", line 194, in _get_directory_for_loading_and_check_export
    dirname = klass._get_directory_for_loading(filename, ext)
  File "/usr/lib/pymodules/python2.6/soya/__init__.py", line 171, in _get_directory_for_loading
    raise ValueError("Cannot find a %s named %s!" % (klass, filename))
ValueError: Cannot find a <class 'soya.Model'> named house!
* Soya3D * Quit...

So i am figuring that because i dont understand how to turn my files into .data files, i will need to learn that. So my question is, how do i use my own models?

© Game Development or respective owner

Related posts about 3d-engines

Related posts about python