-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2bd45c9
commit f68abcb
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
"""Polygon mesh.""" | ||
from shutil import copyfile | ||
import os | ||
|
||
class Mesh: | ||
"""Polygon mesh defined by .obj file and some solid color.""" | ||
|
||
def __init__(self, filename, translation=None, rotation=None, scale=None, color=None, visible=True): | ||
self.filename = filename | ||
self.translation = translation | ||
self.rotation = rotation | ||
self.scale = scale | ||
self.color = color | ||
self.visible = visible | ||
|
||
def get_properties(self, filename): | ||
""" | ||
:return: A dict conteining object properties. They are written into json and interpreted by javascript. | ||
""" | ||
json_dict = { | ||
'type': 'obj', | ||
'filename': os.path.split(self.filename)[-1], | ||
'translation': self.translation, | ||
'rotation': self.rotation, | ||
'scale': self.scale, | ||
'color': self.color, | ||
'visible': self.visible, | ||
} | ||
return json_dict | ||
|
||
def write_binary(self, path): | ||
obj_file = os.path.split(self.filename)[-1] | ||
destination_dir = os.path.dirname(path) | ||
destination_path = os.path.join(destination_dir, obj_file) | ||
if not os.path.exists(destination_path): | ||
copyfile(self.filename, destination_path) |