Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
yuanming-hu committed Sep 25, 2019
1 parent 4dc2123 commit 977ee0b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 17 deletions.
45 changes: 30 additions & 15 deletions examples/diffmpm3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
la = E
max_steps = 512
steps = 512
gravity = 2
gravity = 10
target = [0.8, 0.2, 0.2]
use_apic = False

Expand Down Expand Up @@ -333,18 +333,33 @@ def add_rect(self, x, y, z, w, h, d, actuation, ptype=1):
real_dx = w / w_count
real_dy = h / h_count
real_dz = d / d_count
for i in range(w_count):
for j in range(h_count):
for k in range(d_count):
self.x.append([x + (i + 0.5) * real_dx + self.offset_x,
y + (j + 0.5) * real_dy + self.offset_y,
z + (k + 0.5) * real_dz + self.offset_z])
self.actuator_id.append(actuation)
self.particle_type.append(ptype)
self.n_particles += 1
self.n_solid_particles += int(ptype == 1)
if self.n_particles % 1000 == 0:
print("num particles", self.n_particles)

if ptype == 1:
for i in range(w_count):
for j in range(h_count):
for k in range(d_count):
self.x.append([x + (i + 0.5) * real_dx + self.offset_x,
y + (j + 0.5) * real_dy + self.offset_y,
z + (k + 0.5) * real_dz + self.offset_z])
self.actuator_id.append(actuation)
self.particle_type.append(ptype)
self.n_particles += 1
self.n_solid_particles += int(ptype == 1)
if self.n_particles % 1000 == 0:
print("num particles", self.n_particles)
else:
for i in range(w_count):
for j in range(h_count):
for k in range(d_count):
self.x.append([x + random.random() * w + self.offset_x,
y + random.random() * h + self.offset_y,
z + random.random() * d + self.offset_z])
self.actuator_id.append(actuation)
self.particle_type.append(ptype)
self.n_particles += 1
self.n_solid_particles += int(ptype == 1)
if self.n_particles % 1000 == 0:
print("num particles", self.n_particles)

def set_offset(self, x, y, z):
self.offset_x = x
Expand Down Expand Up @@ -394,8 +409,8 @@ def add_leg(x, y, z):
add_leg(i // 2 * block_size * 2, 0.0, i % 2 * block_size * 2)
for i in range(3):
scene.add_rect(block_size * i, 0, block_size, block_size, block_size * 0.7, block_size, -1, 1)
scene.set_offset(0.1, 0.03, 0.3)
# scene.add_rect(0.0, 0.0, 0.0, 0.6, 0.04, 0.6, -1, 0)
# scene.set_offset(0.1, 0.03, 0.3)
scene.add_rect(0.1, 0.15, 0.1, 0.2, 0.05, 0.2, -1, 0)
# scene.


Expand Down
4 changes: 2 additions & 2 deletions examples/render_diffmpm3d.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import os

for i in range(7, 512, 2):
os.system('python3 diffmpm_renderer.py snow 0040 {}'.format(i))
for i in range(7, 512, 16):
os.system('python3 diffmpm_renderer.py snow 0020 {}'.format(i))

0 comments on commit 977ee0b

Please sign in to comment.