Skip to content

Commit c4d6183

Browse files
committed
Make example runnable from the root
1 parent 7150aa8 commit c4d6183

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

examples/boxes.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,22 @@
1616
C3F_N3F_V3F
1717
T2F_C3F_N3F_V3F
1818
"""
19-
2019
import ctypes
21-
from pyglet.gl import *
20+
import os
2221

22+
from pyglet.gl import *
2323
from pywavefront import visualization, Wavefront
2424

2525
window = pyglet.window.Window(width=1280, height=720)
2626

27-
box1 = Wavefront('data/box/box-V3F.obj')
28-
box2 = Wavefront('data/box/box-C3F_V3F.obj')
29-
box3 = Wavefront('data/box/box-N3F_V3F.obj')
30-
box4 = Wavefront('data/box/box-T2F_V3F.obj')
31-
box5 = Wavefront('data/box/box-T2F_C3F_V3F.obj')
32-
box6 = Wavefront('data/box/box-T2F_N3F_V3F.obj')
27+
root_path = os.path.dirname(__file__)
28+
29+
box1 = Wavefront(os.path.join(root_path, 'data/box/box-V3F.obj'))
30+
box2 = Wavefront(os.path.join(root_path,'data/box/box-C3F_V3F.obj'))
31+
box3 = Wavefront(os.path.join(root_path,'data/box/box-N3F_V3F.obj'))
32+
box4 = Wavefront(os.path.join(root_path,'data/box/box-T2F_V3F.obj'))
33+
box5 = Wavefront(os.path.join(root_path,'data/box/box-T2F_C3F_V3F.obj'))
34+
box6 = Wavefront(os.path.join(root_path,'data/box/box-T2F_N3F_V3F.obj'))
3335

3436
rotation = 0.0
3537
lightfv = ctypes.c_float * 4

examples/globe_complex.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"""This script shows another example of using the PyWavefront module."""
33
# This example was created by intrepid94
44
import ctypes
5+
import os
56
import sys
67
sys.path.append('..')
78

@@ -11,8 +12,11 @@
1112
from pywavefront import visualization
1213
from pywavefront import Wavefront
1314

15+
# Create absolute path from this module
16+
file_abspath = os.path.join(os.path.dirname(__file__), 'data/earth.obj')
17+
1418
rotation = 0.0
15-
meshes = Wavefront('data/earth.obj')
19+
meshes = Wavefront(file_abspath)
1620
window = pyglet.window.Window(1024, 720, caption='Demo', resizable=True)
1721
lightfv = ctypes.c_float * 4
1822
label = pyglet.text.Label(

examples/globe_simple.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python
22
"""This script shows an example of using the PyWavefront module."""
33
import ctypes
4+
import os
45
import sys
56

67
sys.path.append('..')
@@ -11,8 +12,11 @@
1112
from pywavefront import visualization
1213
import pywavefront
1314

15+
# Create absolute path from this module
16+
file_abspath = os.path.join(os.path.dirname(__file__), 'data/uv_sphere.obj')
17+
1418
rotation = 0
15-
meshes = pywavefront.Wavefront('data/uv_sphere.obj')
19+
meshes = pywavefront.Wavefront(file_abspath)
1620
window = pyglet.window.Window()
1721
lightfv = ctypes.c_float * 4
1822

0 commit comments

Comments
 (0)