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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
|
# -*- coding: utf-8 -*-
"""DIFERENCIAL - why the two wheels can turn at different speeds.
Every part is generated in code and moves with the exact kinematics of the
mechanism: w_left + w_right = 2 * w_carrier, and the spider gear spins about
its own axis at (w_right - w_left)/2 relative to the carrier. Pinion and ring
gear keep their ratio: 14 and 43 teeth, with cone half-angles adding up to 90
degrees."""
import math, os, sys
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import bpy
from mathutils import Vector
from base import *
NAME_KEY = "diferencial"
AXIS_X = 1.32 # where the wheels go
R_WHEEL = 0.52
OMEGA = 1.45 # rad/s of the carrier
RADIO_GIRO = 3.9
TRACK_W = 1.70
INCL = -0.72 # strongly diagonal: in 9:16 that is what uses the height
N_COR, N_PIN = 43, 14 # 3.07:1 ratio, like a road differential
G_COR, G_PIN = 72.0, 18.0 # the half-angles add up to 90: that is the meshing condition
N_LAT = 16
X_COR = -0.50 # common apex of ring gear and pinion: far from the spider gears
D_I, D_O = 0.70, 1.00 # the toothed face, the same on both
P_PHASE = math.pi / 2 # so the tooth lands in the gap
P_ESP = -0.62 # opposite hand to the ring gear
P_NEXT = 1.0
# the assembly is 3.68 from end to end; tilted 41 degrees that is 2.77 wide
# and 2.41 high, which is what sets these numbers
FRAMING = [(0, 6.2), (2, 5.0), (3, 4.2), (4, 5.6), (5, 4.6),
(6, 5.0), (7, 5.6), (8, 5.6), (9, 5.8), (10, 5.2)]
DIR_CAM = Vector((0.30, -0.93, 0.21)).normalized()
def alto_en(T, f):
tabla, altos, v = dict(FRAMING), [], FRAMING[0][1]
for i in range(len(T.beats)):
v = tabla.get(i, v)
altos.append(v)
i = 0
for k in range(len(T.beats)):
if f >= T.span(k)[0]:
i = k
start, fin = T.span(i)
p = min(1.0, (f - start) / max(1.0, (fin - start) * 0.55))
return mix_m(altos[i - 1] if i else altos[0], altos[i], p)
def build_scene(T):
sc = scene_setup()
studio_world(0.65) # what the steel reflects
cam = camera_obj((0, -6, 0), (0, 0, 0), lens=50)
cam.data.sensor_fit = 'VERTICAL'
cam.data.sensor_height = 36.0
light_obj("key", 'AREA', (-3.4, -4.6, 4.4), 1400, "blanco", size_u=6.0, sight=(0, 0, 0))
light_obj("fill", 'AREA', (4.2, -3.2, -1.6), 420, "#BFD4FF", size_u=5.0, sight=(0, 0, 0))
light_obj("rim", 'AREA', (-0.8, 4.6, 2.8), 900, "blanco", size_u=4.0, sight=(0, 0, 0))
M = {
"acero": metal("acero", "#B7BEC9", rough=0.22),
"acero2": metal("acero2", "#9BA3B0", rough=0.30),
"fundido": metal("fundido", "#5E6774", rough=0.62, met=0.85),
"eje_i": metal("eje_i", "#C2C8D2", rough=0.24),
"eje_d": metal("eje_d", "#C2C8D2", rough=0.24),
"goma": material("goma", "#1E222C", rough=0.52),
"alu": metal("alu", "#CBD3DE", rough=0.15),
"freno": metal("freno", "#79818E", rough=0.45, met=0.9),
}
# --- top view: the car turning --------------------------------------
floor_obj = bpy.data.objects.new("suelo_g", None)
bpy.context.collection.objects.link(floor_obj)
arc_list, wheels_a = [], []
for k, (rr, c) in enumerate(((RADIO_GIRO - TRACK_W / 2, "rosa"),
(RADIO_GIRO + TRACK_W / 2, "verde"))):
pts = []
for i in range(120):
th = -0.62 + 1.24 * i / 119.0
pts.append((-RADIO_GIRO + rr * math.cos(th), rr * math.sin(th), 0.0))
cu = curve_poly(f"arco{k}", [pts], thickness_px=0.045, radios=[[0.0] * 120],
mat=material(f"m_arco{k}", c, emit=2.4, rough=0.5))
cu.parent = floor_obj
arc_list.append((cu, pts))
r = full_wheel(f"ra{k}", M, R=R_WHEEL, r=0.185, width_px=0.28)
r.parent = floor_obj
wheels_a.append(r)
axis_a = cylinder("eje_a", 0.075, TRACK_W, M["acero2"])
axis_a.parent = floor_obj
patina = curve_poly("patina", [[(0, 0, 0)] * 60], thickness_px=0.11,
radios=[[0.0] * 60], mat=material("m_pat", "blanco", emit=3.4))
patina.parent = floor_obj
# --- the differential --------------------------------------------------
diff = bpy.data.objects.new("dif", None)
bpy.context.collection.objects.link(diff)
diff.scale = (0, 0, 0)
cage = bpy.data.objects.new("jaula", None)
bpy.context.collection.objects.link(cage)
cage.parent = diff
# carrier housing: two annular flanges and two curved walls around the pin
# axis. The +-Y sides stay open: that is where the gears show, which is how a
# real differential housing looks
# everything in the carrier stays inside r=0.52: the pinion never goes below
# r=0.59, so the carrier can spin without running over it
for sx in (0.58, -0.58):
br = flat_ring(f"brida{sx}", 0.13, 0.52, 0.08, M["fundido"])
br.rotation_euler = (0, math.pi / 2, 0)
br.location = (sx, 0, 0)
br.parent = cage
for k, center_pt in enumerate((math.pi / 2, -math.pi / 2)):
pared = ring_sector(f"pared{k}", 0.43, 0.52, 1.16,
center_pt - 0.62, center_pt + 0.62, M["fundido"])
pared.rotation_euler = (0, math.pi / 2, 0)
pared.parent = cage
bolt = cylinder("perno", 0.062, 1.00, M["acero2"])
bolt.parent = cage
corona = bevel_gear("corona", (1, 0, 0), N=N_COR, gamma=G_COR,
d_i=D_I, d_o=D_O, alto=0.042, mat=M["acero"],
spiral=0.62, thickness=0.14, gap_m=0.58,
per_tooth=24)
corona.location = (X_COR, 0, 0)
corona.parent = cage
screws("bulones", 10, 0.78, -0.11, largo=0.10, r_t=0.035,
mat=M["acero2"], padre=cage)
lat = {}
for nm_key, axis_obj, sx in (("izq", (-1, 0, 0), -1), ("der", (1, 0, 0), 1)):
g = bpy.data.objects.new(f"lat_{nm_key}", None)
bpy.context.collection.objects.link(g)
g.parent = diff
eng = bevel_gear(f"eng_{nm_key}", axis_obj, N=N_LAT, gamma=45.0,
d_i=0.26, d_o=0.50, alto=0.042, mat=M["acero"],
spiral=0.30, thickness=0.12, gap_m=0.09)
eng.parent = g
# stepped half-shaft + flange
for (largo, radio, x0) in ((0.48, 0.110, 0.50), (AXIS_X - 0.82, 0.080, 0.95)):
se = cylinder(f"se_{nm_key}_{radio}", radio, largo, M[f"eje_{nm_key[0]}"])
se.rotation_euler = (0, math.pi / 2, 0)
se.location = (sx * x0, 0, 0)
se.parent = g
flange = flat_ring(f"bw_{nm_key}", 0.09, 0.22, 0.07, M["acero2"])
flange.rotation_euler = (0, math.pi / 2, 0)
flange.location = (sx * (AXIS_X - 0.20), 0, 0)
flange.parent = g
wheel_obj = full_wheel(f"rue_{nm_key}", M, R=R_WHEEL, r=0.185, width_px=0.28)
wheel_obj.location = (sx * AXIS_X, 0, 0)
wheel_obj.parent = g
lat[nm_key] = g
sat = []
for k, axis_obj in enumerate(((0, 0, 1), (0, 0, -1))):
g = bpy.data.objects.new(f"sat{k}", None)
bpy.context.collection.objects.link(g)
g.parent = cage
eng = bevel_gear(f"eng_s{k}", axis_obj, N=N_LAT, gamma=45.0,
d_i=0.26, d_o=0.50, alto=0.042, mat=M["acero2"],
spiral=-0.30, thickness=0.12, gap_m=0.09, phase=math.pi)
eng.parent = g
if k == 0:
p = sphere(f"testigo{k}", 0.050, material("m_test", "ambar", emit=3.0))
p.location = (0.30, 0.0, 0.42)
p.parent = g
sat.append(g)
input_shaft = bpy.data.objects.new("entrada", None)
bpy.context.collection.objects.link(input_shaft)
input_shaft.parent = diff
# same face as the ring gear, opposite-hand spiral and a phase so the
# tooth lands in the gap
pinion = bevel_gear("pinon", (0, -1, 0), N=N_PIN, gamma=G_PIN,
d_i=D_I, d_o=D_O, alto=0.042, mat=M["acero"],
spiral=P_ESP, thickness=0.12, gap_m=0.07,
phase=P_PHASE, per_tooth=24)
pinion.location = (X_COR, 0, 0)
pinion.parent = input_shaft
cardan_joint = cylinder("cardan", 0.095, 1.30, M["acero2"])
cardan_joint.rotation_euler = (math.pi / 2, 0, 0)
cardan_joint.location = (X_COR, -1.50, 0)
cardan_joint.parent = input_shaft
fork = flat_ring("horquilla", 0.10, 0.24, 0.10, M["acero2"])
fork.location = (X_COR
|