/
objects.py
50 lines (38 loc) · 1.3 KB
/
objects.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
45
46
47
48
49
50
import math
import numpy as np
import trimesh
from . import Mesh, Node, quaternion
def Sphere():
sphere = trimesh.creation.capsule(radius=0.375, height=0)
mesh = Mesh.from_trimesh(sphere, smooth=True)
node = Node(mesh=mesh, translation=np.array([0, 0.375, 0]))
return node
def Box():
sphere = trimesh.creation.box(extents=np.array([0.75, 0.75, 0.75]))
mesh = Mesh.from_trimesh(sphere, smooth=False)
node = Node(mesh=mesh, translation=np.array([0, 0.375, 0]))
return node
def Capsule():
sphere = trimesh.creation.capsule(radius=0.25, height=0.75)
mesh = Mesh.from_trimesh(sphere, smooth=True)
node = Node(
mesh=mesh,
rotation=quaternion.from_pitch(math.pi / 2),
translation=np.array([0, 0.75, 0]))
return node
def Cylinder():
sphere = trimesh.creation.cylinder(radius=0.375, height=0.75)
mesh = Mesh.from_trimesh(sphere, smooth=False)
node = Node(
mesh=mesh,
rotation=quaternion.from_pitch(math.pi / 2),
translation=np.array([0, 0.375, 0]))
return node
def Icosahedron():
sphere = trimesh.creation.icosahedron()
mesh = Mesh.from_trimesh(sphere, smooth=False)
node = Node(
mesh=mesh,
scale=np.array([0.35, 0.35, 0.35]),
translation=np.array([0, 0.35, 0]))
return node