-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathentity_factory.py
45 lines (37 loc) · 1.87 KB
/
entity_factory.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import bpy
from .entities import LightEntity, BoxEntity, QuadEntity, SphereEntity, CylinderEntity, ConeEntity, ImageEntity, WebEntity, ModelEntity, TextEntity, CustomModelEntity
from .asset_loader import AssetLoader
class EntityFactory(object):
@staticmethod
def matchName(obj, name):
return obj.name == name or obj.name.startswith(name + ".")
@staticmethod
def createEntity(obj):
entity = None
if obj.type == 'LIGHT':
if (EntityFactory.matchName(obj, "Light") or EntityFactory.matchName(obj, "Point") or EntityFactory.matchName(obj, "Spot")):
light = obj.data
if light.type == 'POINT' or light.type == 'SPOT':
entity = LightEntity(obj, light)
if obj.type == 'MESH':
if (EntityFactory.matchName(obj, "Cube") or EntityFactory.matchName(obj, "Box")):
entity = BoxEntity(obj)
elif (EntityFactory.matchName(obj, "Plane") or EntityFactory.matchName(obj, "Quad")):
entity = QuadEntity(obj)
elif (EntityFactory.matchName(obj, "Icosphere") or EntityFactory.matchName(obj, "Sphere")):
entity = SphereEntity(obj)
elif (EntityFactory.matchName(obj, "Cylinder")):
entity = CylinderEntity(obj)
elif (EntityFactory.matchName(obj, "Cone")):
entity = ConeEntity(obj)
elif EntityFactory.matchName(obj, "Image"):
entity = ImageEntity(obj)
elif EntityFactory.matchName(obj, "Web"):
entity = WebEntity(obj)
elif EntityFactory.matchName(obj, "Text"):
entity = TextEntity(obj)
elif EntityFactory.matchName(obj, "Model"):
entity = CustomModelEntity(obj)
elif AssetLoader.getOverteModelUrl(obj):
entity = ModelEntity(obj)
return entity