def __init__(self, icp): #icp is initial cranicm pointi self._cranicm_radius = 3.0 self._neck_radius = 1.5 self._neck_length = 6.0 self._init_cranicm_point = icp self._init_neck_toWorld = tf.translate(Vector( icp.x, icp.y - 3, icp.z)) * tf.scale( Vector(1, self._neck_length, 1)) * tf.rotate( Vector(1, 0, 0), -90) * tf.translate(Vector(0, 0, -0.5)) self.cranicm_prop = { 'type': 'sphere', 'center': self._init_cranicm_point, 'radius': self._cranicm_radius, 'bsdf': { 'type': 'ward', 'alphaU': 0.003, 'alphaV': 0.003, 'specularReflectance': Spectrum(0.01), 'diffuseReflectance': Spectrum([0.05, 0.05, 0.05]) } } self.neck_prop = { 'type': 'cylinder', 'toWorld': self._init_neck_toWorld, 'radius': self._neck_radius, 'bsdf': { 'type': 'ward', 'alphaU': 0.003, 'alphaV': 0.003, 'specularReflectance': Spectrum(0.01), 'diffuseReflectance': Spectrum([0.05, 0.05, 0.05]) } }
def set_joint_angles(self, shoulder_pitch, shoulder_yaw, shoulder_roll, elbow_angle): self._shoulder_pitch = shoulder_pitch self._shoulder_yaw = shoulder_yaw self._shoulder_roll = shoulder_roll self._elbow_angle = elbow_angle # sto is the translate "shoulder to origin" sto = tf.translate(Vector(-self.shoulder_joint_prop['center'][0], -self.shoulder_joint_prop['center'][1], -self.shoulder_joint_prop['center'][2])) # ots is the translate "shoulder from origin" ots = tf.translate(Vector(self.shoulder_joint_prop['center'][0], self.shoulder_joint_prop['center'][1], self.shoulder_joint_prop['center'][2])) self.upperarm_prop['toWorld'] = ots * self._create_xyz_rotation(shoulder_pitch, shoulder_yaw, shoulder_roll) * sto * self._init_upperarm_toWorld self.upperarm_endcap_prop['center'] = ots * self._create_xyz_rotation(shoulder_pitch, shoulder_yaw, shoulder_roll) * sto * self._init_upperarm_end_point self.elbow_joint_prop['center'] = ots * self._create_xyz_rotation(shoulder_pitch, shoulder_yaw, shoulder_roll) * sto * self._init_elbow_point self.forearm_endcap_prop['center'] = ots * self._create_xyz_rotation(shoulder_pitch, shoulder_yaw, shoulder_roll) * sto * self._init_forearm_start_point self.forearm_prop['toWorld'] = ots * self._create_xyz_rotation(shoulder_pitch, shoulder_yaw, shoulder_roll) * sto * self._init_forearm_toWorld self.hand_prop['center'] = ots * self._create_xyz_rotation(shoulder_pitch, shoulder_yaw, shoulder_roll) * sto * self._init_hand_point # eto is the translate "elbow to origin" eto = tf.translate(Vector(-self.elbow_joint_prop['center'][0], -self.elbow_joint_prop['center'][1], -self.elbow_joint_prop['center'][2])) # ots is the translate "origin to shoulder" ote = tf.translate(Vector(self.elbow_joint_prop['center'][0], self.elbow_joint_prop['center'][1], self.elbow_joint_prop['center'][2])) elbow_axis = self.upperarm_prop['toWorld'] * (-self._slocal_axes['x']) self.forearm_endcap_prop['center'] = ote * tf.rotate(elbow_axis, elbow_angle) * eto * self.forearm_endcap_prop['center'] self.forearm_prop['toWorld'] = ote * tf.rotate(elbow_axis, elbow_angle) * eto * self.forearm_prop['toWorld'] self.hand_prop['center'] = ote * tf.rotate(elbow_axis, elbow_angle) * eto * self.hand_prop['center']
def set_joint_angles(self, hip_pitch, hip_yaw, hip_roll, knee_angle): self._hip_pitch = hip_pitch self._hip_yaw = hip_yaw self._hip_roll = hip_roll self._knee_angle = knee_angle # sto is the translate "hip to origin" sto = tf.translate(Vector(-self.hip_joint_prop['center'][0], -self.hip_joint_prop['center'][1], -self.hip_joint_prop['center'][2])) # ots is the translate "hip from origin" ots = tf.translate(Vector(self.hip_joint_prop['center'][0], self.hip_joint_prop['center'][1], self.hip_joint_prop['center'][2])) self.thigh_prop['toWorld'] = ots * self._create_xyz_rotation(hip_pitch, hip_yaw, hip_roll) * sto * self._init_thigh_toWorld self.thigh_endcap_prop['center'] = ots * self._create_xyz_rotation(hip_pitch, hip_yaw, hip_roll) * sto * self._init_thigh_end_point self.knee_joint_prop['center'] = ots * self._create_xyz_rotation(hip_pitch, hip_yaw, hip_roll) * sto * self._init_knee_point self.calf_endcap_prop['center'] = ots * self._create_xyz_rotation(hip_pitch, hip_yaw, hip_roll) * sto * self._init_calf_start_point self.calf_prop['toWorld'] = ots * self._create_xyz_rotation(hip_pitch, hip_yaw, hip_roll) * sto * self._init_calf_toWorld self.foot_prop['center'] = ots * self._create_xyz_rotation(hip_pitch, hip_yaw, hip_roll) * sto * self._init_foot_point # eto is the translate "knee to origin" eto = tf.translate(Vector(-self.knee_joint_prop['center'][0], -self.knee_joint_prop['center'][1], -self.knee_joint_prop['center'][2])) # ots is the translate "origin to hip" ote = tf.translate(Vector(self.knee_joint_prop['center'][0], self.knee_joint_prop['center'][1], self.knee_joint_prop['center'][2])) knee_axis = self.thigh_prop['toWorld'] * self._hlocal_axes['x'] self.calf_endcap_prop['center'] = ote * tf.rotate(knee_axis, knee_angle) * eto * self.calf_endcap_prop['center'] self.calf_prop['toWorld'] = ote * tf.rotate(knee_axis, knee_angle) * eto * self.calf_prop['toWorld'] self.foot_prop['center'] = ote * tf.rotate(knee_axis, knee_angle) * eto * self.foot_prop['center']
def set_joint_angles(self, shoulder_pitch, shoulder_yaw, shoulder_roll, elbow_angle): self._shoulder_pitch = shoulder_pitch self._shoulder_yaw = shoulder_yaw self._shoulder_roll = shoulder_roll self._elbow_angle = elbow_angle # sto is the translate "shoulder to origin" sto = tf.translate( Vector(-self.shoulder_joint_prop['center'][0], -self.shoulder_joint_prop['center'][1], -self.shoulder_joint_prop['center'][2])) # ots is the translate "shoulder from origin" ots = tf.translate( Vector(self.shoulder_joint_prop['center'][0], self.shoulder_joint_prop['center'][1], self.shoulder_joint_prop['center'][2])) self.upperarm_prop['toWorld'] = ots * self._create_xyz_rotation( shoulder_pitch, shoulder_yaw, shoulder_roll) * sto * self._init_upperarm_toWorld self.upperarm_endcap_prop['center'] = ots * self._create_xyz_rotation( shoulder_pitch, shoulder_yaw, shoulder_roll) * sto * self._init_upperarm_end_point self.elbow_joint_prop['center'] = ots * self._create_xyz_rotation( shoulder_pitch, shoulder_yaw, shoulder_roll) * sto * self._init_elbow_point self.forearm_endcap_prop['center'] = ots * self._create_xyz_rotation( shoulder_pitch, shoulder_yaw, shoulder_roll) * sto * self._init_forearm_start_point self.forearm_prop['toWorld'] = ots * self._create_xyz_rotation( shoulder_pitch, shoulder_yaw, shoulder_roll) * sto * self._init_forearm_toWorld self.hand_prop['center'] = ots * self._create_xyz_rotation( shoulder_pitch, shoulder_yaw, shoulder_roll) * sto * self._init_hand_point # eto is the translate "elbow to origin" eto = tf.translate( Vector(-self.elbow_joint_prop['center'][0], -self.elbow_joint_prop['center'][1], -self.elbow_joint_prop['center'][2])) # ots is the translate "origin to shoulder" ote = tf.translate( Vector(self.elbow_joint_prop['center'][0], self.elbow_joint_prop['center'][1], self.elbow_joint_prop['center'][2])) elbow_axis = self.upperarm_prop['toWorld'] * (-self._slocal_axes['x']) self.forearm_endcap_prop['center'] = ote * tf.rotate( elbow_axis, elbow_angle) * eto * self.forearm_endcap_prop['center'] self.forearm_prop['toWorld'] = ote * tf.rotate( elbow_axis, elbow_angle) * eto * self.forearm_prop['toWorld'] self.hand_prop['center'] = ote * tf.rotate( elbow_axis, elbow_angle) * eto * self.hand_prop['center']
def __init__(self, itp): # itp is initial torso point self._torso_radius = 5.5 self._torso_length = 18.0 self._init_clavile_toWorld = tf.translate( Vector(itp.x, itp.y + (self._torso_length / 2), itp.z)) * tf.scale( Vector(self._torso_radius, 1, self._torso_radius)) * tf.rotate( Vector(1, 0, 0), -90) self._init_torso_cylinder_toWorld = tf.translate( Vector(itp.x, itp.y, itp.z)) * tf.scale( Vector(1, self._torso_length, 1)) * tf.rotate( Vector(1, 0, 0), -90) * tf.translate(Vector(0, 0, -0.5)) self._init_hip_toWorld = tf.translate( Vector(itp.x, itp.y - (self._torso_length / 2), itp.z)) * tf.scale( Vector(self._torso_radius, 1, self._torso_radius)) * tf.rotate( Vector(1, 0, 0), 90) self._torso_cylinder_point = itp self.clavile_prop = { 'type': 'disk', 'toWorld': self._init_clavile_toWorld, 'bsdf': { 'type': 'ward', 'alphaU': 0.003, 'alphaV': 0.003, 'specularReflectance': Spectrum(0.01), 'diffuseReflectance': Spectrum([0.05, 0.05, 0.05]) } } self.torso_cylinder_prop = { 'type': 'cylinder', 'toWorld': self._init_torso_cylinder_toWorld, 'radius': self._torso_radius, 'bsdf': { 'type': 'ward', 'alphaU': 0.003, 'alphaV': 0.003, 'specularReflectance': Spectrum(0.01), 'diffuseReflectance': Spectrum([0.05, 0.05, 0.05]) } } self.hip_prop = { 'type': 'disk', 'toWorld': self._init_hip_toWorld, 'bsdf': { 'type': 'ward', 'alphaU': 0.003, 'alphaV': 0.003, 'specularReflectance': Spectrum(0.01), 'diffuseReflectance': Spectrum([0.05, 0.05, 0.05]) } }
def horiz_move(self, gx, gy, gz): movement = tf.translate(Vector( gx, gy, gz)) # Affine matrix for horizontal movement. self._init_cranicm_point = movement * self._init_cranicm_point self._init_neck_toWorld = movement * self._init_neck_toWorld self.cranicm_prop['center'] = movement * self.cranicm_prop['center'] self.neck_prop['toWorld'] = movement * self.neck_prop['toWorld']
def __add_cone(self, shape): y_dir = np.array([0.0, 1.0, 0.0]) v = shape.end_points[1] - shape.end_points[0] center = 0.5 * (shape.end_points[0] + shape.end_points[1]) height = norm(v) scale = Transform.scale(Vector(shape.radius, height, shape.radius)) axis = np.cross(y_dir, v) axis_len = norm(axis) angle = degrees(atan2(axis_len, np.dot(y_dir, v))) if (axis_len > 1e-6): axis /= axis_len rotate = Transform.rotate(Vector(*axis), angle) else: axis = np.array([1.0, 0.0, 0.0]) rotate = Transform.rotate(Vector(*axis), angle) translate = Transform.translate(Vector(*center)) cone_file = self.file_resolver.resolve("cone.ply") cone_transform = translate * rotate * scale setting = { "type": "ply", "filename": cone_file, "toWorld": cone_transform } return setting
def __add_floor(self): rotate_transform = Transform.rotate(Vector(-1, 0, 0), 90) scale_transform = Transform.scale(Vector(100, 100, 100)) translate_transform = Transform.translate( Vector(0.0, self.floor_height, 0.0)) total_transform = translate_transform * scale_transform\ * rotate_transform if self.scene.active_view.background == "d": reflectance = Spectrum(0.05) elif self.scene.active_view.background == "l": reflectance = Spectrum(0.5) else: reflectance = Spectrum(0.0) floor = self.plgr.create({ "type": "rectangle", "toWorld": total_transform, "bsdf": { "type": "roughdiffuse", "diffuseReflectance": reflectance, "alpha": 0.5 } }) self.mitsuba_scene.addChild(floor)
def __get_normalize_transform(self, active_view): centroid = active_view.center scale = active_view.scale normalize_transform = Transform.scale(Vector(scale, scale, scale)) *\ Transform.translate(Vector(*(-1 * centroid))) return normalize_transform
def set_joint_angles(self, hip_pitch, hip_yaw, hip_roll, knee_angle): self._hip_pitch = hip_pitch self._hip_yaw = hip_yaw self._hip_roll = hip_roll self._knee_angle = knee_angle # sto is the translate "hip to origin" sto = tf.translate( Vector(-self.hip_joint_prop['center'][0], -self.hip_joint_prop['center'][1], -self.hip_joint_prop['center'][2])) # ots is the translate "hip from origin" ots = tf.translate( Vector(self.hip_joint_prop['center'][0], self.hip_joint_prop['center'][1], self.hip_joint_prop['center'][2])) self.thigh_prop['toWorld'] = ots * self._create_xyz_rotation( hip_pitch, hip_yaw, hip_roll) * sto * self._init_thigh_toWorld self.thigh_endcap_prop['center'] = ots * self._create_xyz_rotation( hip_pitch, hip_yaw, hip_roll) * sto * self._init_thigh_end_point self.knee_joint_prop['center'] = ots * self._create_xyz_rotation( hip_pitch, hip_yaw, hip_roll) * sto * self._init_knee_point self.calf_endcap_prop['center'] = ots * self._create_xyz_rotation( hip_pitch, hip_yaw, hip_roll) * sto * self._init_calf_start_point self.calf_prop['toWorld'] = ots * self._create_xyz_rotation( hip_pitch, hip_yaw, hip_roll) * sto * self._init_calf_toWorld self.foot_prop['center'] = ots * self._create_xyz_rotation( hip_pitch, hip_yaw, hip_roll) * sto * self._init_foot_point # eto is the translate "knee to origin" eto = tf.translate( Vector(-self.knee_joint_prop['center'][0], -self.knee_joint_prop['center'][1], -self.knee_joint_prop['center'][2])) # ots is the translate "origin to hip" ote = tf.translate( Vector(self.knee_joint_prop['center'][0], self.knee_joint_prop['center'][1], self.knee_joint_prop['center'][2])) knee_axis = self.thigh_prop['toWorld'] * self._hlocal_axes['x'] self.calf_endcap_prop['center'] = ote * tf.rotate( knee_axis, knee_angle) * eto * self.calf_endcap_prop['center'] self.calf_prop['toWorld'] = ote * tf.rotate( knee_axis, knee_angle) * eto * self.calf_prop['toWorld'] self.foot_prop['center'] = ote * tf.rotate( knee_axis, knee_angle) * eto * self.foot_prop['center']
def __init__(self, itp): # itp is initial torso point self._torso_radius = 5.5 self._torso_length = 18.0 self._init_clavile_toWorld = tf.translate(Vector(itp.x, itp.y+(self._torso_length/2), itp.z)) * tf.scale(Vector(self._torso_radius, 1, self._torso_radius)) * tf.rotate(Vector(1, 0, 0), -90) self._init_torso_cylinder_toWorld = tf.translate(Vector(itp.x, itp.y, itp.z)) * tf.scale(Vector(1, self._torso_length, 1)) * tf.rotate(Vector(1, 0, 0), -90) * tf.translate(Vector(0, 0, -0.5)) self._init_hip_toWorld = tf.translate(Vector(itp.x, itp.y-(self._torso_length/2), itp.z)) * tf.scale(Vector(self._torso_radius, 1, self._torso_radius)) * tf.rotate(Vector(1, 0, 0), 90) self._torso_cylinder_point = itp self.clavile_prop = { 'type' : 'disk', 'toWorld': self._init_clavile_toWorld, 'bsdf' : { 'type' : 'ward', 'alphaU' : 0.003, 'alphaV' : 0.003, 'specularReflectance' : Spectrum(0.01), 'diffuseReflectance' : Spectrum([0.05, 0.05, 0.05]) } } self.torso_cylinder_prop = { 'type' : 'cylinder', 'toWorld': self._init_torso_cylinder_toWorld, 'radius' : self._torso_radius, 'bsdf' : { 'type' : 'ward', 'alphaU' : 0.003, 'alphaV' : 0.003, 'specularReflectance' : Spectrum(0.01), 'diffuseReflectance' : Spectrum([0.05, 0.05, 0.05]) } } self.hip_prop = { 'type' : 'disk', 'toWorld': self._init_hip_toWorld, 'bsdf' : { 'type' : 'ward', 'alphaU' : 0.003, 'alphaV' : 0.003, 'specularReflectance' : Spectrum(0.01), 'diffuseReflectance' : Spectrum([0.05, 0.05, 0.05]) } }
def horiz_move(self, gx, gy, gz): movement = tf.translate(Vector(gx, gy, gz)) # Affine matrix for horizontal movement. self._init_clavile_toWorld = movement * self._init_clavile_toWorld self._init_torso_cylinder_toWorld = movement * self._init_torso_cylinder_toWorld self._init_hip_toWorld = movement * self._init_hip_toWorld self.clavile_prop['toWorld'] = movement * self.clavile_prop['toWorld'] self.torso_cylinder_prop['toWorld'] = movement * self.torso_cylinder_prop['toWorld'] self.hip_prop['toWorld'] = movement * self.hip_prop['toWorld'] self._torso_cylinder_point = movement * self._torso_cylinder_point
def horiz_move(self, gx, gy, gz): movement = tf.translate(Vector(gx, gy, gz)) # Affine matrix for horizontal movement. self._body_center = movement * self._init_torso_center self.head.horiz_move(x, y, z) self.torso.horiz_move(x, y, z) self.left_arm.horiz_move(x, y, z) self.right_arm.horiz_move(x, y, z) if self._lower_body_flag: self.left_leg.horiz_move(x, y, z) self.right_leg.horiz_move(x, y, z)
def horiz_move(self, gx, gy, gz): movement = tf.translate(Vector( gx, gy, gz)) # Affine matrix for horizontal movement. self._body_center = movement * self._init_torso_center self.head.horiz_move(x, y, z) self.torso.horiz_move(x, y, z) self.left_arm.horiz_move(x, y, z) self.right_arm.horiz_move(x, y, z) if self._lower_body_flag: self.left_leg.horiz_move(x, y, z) self.right_leg.horiz_move(x, y, z)
def horiz_move(self, gx, gy, gz): movement = tf.translate(Vector( gx, gy, gz)) # Affine matrix for horizontal movement. self._init_clavile_toWorld = movement * self._init_clavile_toWorld self._init_torso_cylinder_toWorld = movement * self._init_torso_cylinder_toWorld self._init_hip_toWorld = movement * self._init_hip_toWorld self.clavile_prop['toWorld'] = movement * self.clavile_prop['toWorld'] self.torso_cylinder_prop[ 'toWorld'] = movement * self.torso_cylinder_prop['toWorld'] self.hip_prop['toWorld'] = movement * self.hip_prop['toWorld'] self._torso_cylinder_point = movement * self._torso_cylinder_point
def horiz_move(self, gx, gy, gz): movement = tf.translate(Vector(gx, gy, gz)) # Affine matrix for horizontal movement. self._init_shoulder_point = movement * self._init_shoulder_point self._init_upperarm_toWorld = movement * self._init_upperarm_toWorld self._init_upperarm_end_point = movement * self._init_upperarm_end_point self._init_elbow_point = movement * self._init_elbow_point self._init_forearm_start_point = movement * self._init_forearm_start_point self._init_hand_point = movement * self._init_hand_point self._init_forearm_toWorld = movement * self._init_forearm_toWorld self.shoulder_joint_prop['center'] = movement * self.shoulder_joint_prop['center'] self.upperarm_endcap_prop['center'] = movement * self.upperarm_endcap_prop['center'] self.upperarm_prop['toWorld'] = movement * self.upperarm_prop['toWorld'] self.elbow_joint_prop['center'] = movement * self.elbow_joint_prop['center'] self.forearm_endcap_prop['center'] = movement * self.forearm_endcap_prop['center'] self.forearm_prop['toWorld'] = movement * self.forearm_prop['toWorld'] self.hand_prop['center'] = movement * self.hand_prop['center']
def horiz_move(self, gx, gy, gz): movement = tf.translate(Vector(gx, gy, gz)) # Affine matrix for horizontal movement. self._init_hip_point = movement * self._init_hip_point self._init_thigh_toWorld = movement * self._init_thigh_toWorld self._init_thigh_end_point = movement * self._init_thigh_end_point self._init_knee_point = movement * self._init_knee_point self._init_calf_start_point = movement * self._init_calf_start_point self._init_foot_point = movement * self._init_foot_point self._init_calf_toWorld = movement * self._init_calf_toWorld self.hip_joint_prop['center'] = movement * self.hip_joint_prop['center'] self.thigh_endcap_prop['center'] = movement * self.thigh_endcap_prop['center'] self.thigh_prop['toWorld'] = movement * self.thigh_prop['toWorld'] self.knee_joint_prop['center'] = movement * self.knee_joint_prop['center'] self.calf_endcap_prop['center'] = movement * self.calf_endcap_prop['center'] self.calf_prop['toWorld'] = movement * self.calf_prop['toWorld'] self.foot_prop['center'] = movement * self.foot_prop['center']
def createRenderJob(self): self.scene = self.pmgr.create({ 'type' : 'scene', 'sphere' : { 'type' : 'sphere', }, 'envmap' : { 'type' : 'sky' }, 'sensor' : { 'type' : 'perspective', 'toWorld' : Transform.translate(Vector(0, 0, -5)), 'sampler' : { 'type' : 'halton', 'sampleCount' : 64 } } }) return RenderJob('rjob', self.scene, self.queue)
def horiz_move(self, gx, gy, gz): movement = tf.translate(Vector( gx, gy, gz)) # Affine matrix for horizontal movement. self._init_hip_point = movement * self._init_hip_point self._init_thigh_toWorld = movement * self._init_thigh_toWorld self._init_thigh_end_point = movement * self._init_thigh_end_point self._init_knee_point = movement * self._init_knee_point self._init_calf_start_point = movement * self._init_calf_start_point self._init_foot_point = movement * self._init_foot_point self._init_calf_toWorld = movement * self._init_calf_toWorld self.hip_joint_prop[ 'center'] = movement * self.hip_joint_prop['center'] self.thigh_endcap_prop[ 'center'] = movement * self.thigh_endcap_prop['center'] self.thigh_prop['toWorld'] = movement * self.thigh_prop['toWorld'] self.knee_joint_prop[ 'center'] = movement * self.knee_joint_prop['center'] self.calf_endcap_prop[ 'center'] = movement * self.calf_endcap_prop['center'] self.calf_prop['toWorld'] = movement * self.calf_prop['toWorld'] self.foot_prop['center'] = movement * self.foot_prop['center']
def horiz_move(self, gx, gy, gz): movement = tf.translate(Vector( gx, gy, gz)) # Affine matrix for horizontal movement. self._init_shoulder_point = movement * self._init_shoulder_point self._init_upperarm_toWorld = movement * self._init_upperarm_toWorld self._init_upperarm_end_point = movement * self._init_upperarm_end_point self._init_elbow_point = movement * self._init_elbow_point self._init_forearm_start_point = movement * self._init_forearm_start_point self._init_hand_point = movement * self._init_hand_point self._init_forearm_toWorld = movement * self._init_forearm_toWorld self.shoulder_joint_prop[ 'center'] = movement * self.shoulder_joint_prop['center'] self.upperarm_endcap_prop[ 'center'] = movement * self.upperarm_endcap_prop['center'] self.upperarm_prop[ 'toWorld'] = movement * self.upperarm_prop['toWorld'] self.elbow_joint_prop[ 'center'] = movement * self.elbow_joint_prop['center'] self.forearm_endcap_prop[ 'center'] = movement * self.forearm_endcap_prop['center'] self.forearm_prop['toWorld'] = movement * self.forearm_prop['toWorld'] self.hand_prop['center'] = movement * self.hand_prop['center']
def __init__(self, isp): # isp is initial shoulder point self._upperarm_radius = 1.0 self._upperarm_length = 6.0 self._elbow_radius = 1.0 self._forearm_radius = 1.0 self._forearm_length = 6.0 self._init_shoulder_point = isp # == _init_upperarm_start_point self._init_upperarm_end_point = Point(isp.x, isp.y - self._upperarm_length, isp.z) self._init_upperarm_toWorld = tf.translate( Vector(isp.x, isp.y - (self._upperarm_length / 2), isp.z)) * tf.scale( Vector(1, self._upperarm_length, 1)) * tf.rotate( Vector(1, 0, 0), -90) * tf.translate( Vector(0, 0, -0.5)) self._init_elbow_point = Point( isp.x, isp.y - (self._upperarm_length + self._upperarm_radius + self._elbow_radius), isp.z) self._init_forearm_start_point = Point( isp.x, isp.y - (self._upperarm_length + self._upperarm_radius + self._elbow_radius * 2 + self._forearm_radius), isp.z) self._init_hand_point = Point( isp.x, isp.y - (self._upperarm_length + self._upperarm_radius + self._elbow_radius * 2 + self._forearm_radius + self._forearm_length), isp.z) # == _init_forearm_end_point self._init_forearm_toWorld = tf.translate( Vector( isp.x, isp.y - (self._upperarm_length + self._upperarm_radius + self._elbow_radius * 2 + self._forearm_radius + self._forearm_length / 2), isp.z)) * tf.scale( Vector(1, self._forearm_length, 1)) * tf.rotate( Vector(1, 0, 0), -90) * tf.translate( Vector(0, 0, -0.5)) # local axes at shoulder self._slocal_axes = { 'x': Vector(1, 0, 0), 'y': Vector(0, 1, 0), 'z': Vector(0, 0, 1) } # rotate angle of local axes at shoulder self._slocal_axes_rotate_angle = {'pitch': 0, 'yaw': 0, 'roll': 0} self._shoulder_pitch = 0 self._shoulder_yaw = 0 self._shoulder_roll = 0 self._elbow_angle = 0 self.shoulder_joint_prop = { 'type': 'sphere', 'center': self._init_shoulder_point, 'radius': self._upperarm_radius, 'bsdf': { 'type': 'ward', 'alphaU': 0.003, 'alphaV': 0.003, 'specularReflectance': Spectrum(0.01), 'diffuseReflectance': Spectrum([0.05, 0.05, 0.05]) } } self.upperarm_prop = { 'type': 'cylinder', 'toWorld': self._init_upperarm_toWorld, 'radius': self._upperarm_radius, 'bsdf': { 'type': 'ward', 'alphaU': 0.003, 'alphaV': 0.003, 'specularReflectance': Spectrum(0.01), 'diffuseReflectance': Spectrum([0.05, 0.05, 0.05]) } } self.upperarm_endcap_prop = { 'type': 'sphere', 'center': self._init_upperarm_end_point, 'radius': self._upperarm_radius, 'bsdf': { 'type': 'ward', 'alphaU': 0.003, 'alphaV': 0.003, 'specularReflectance': Spectrum(0.01), 'diffuseReflectance': Spectrum([0.05, 0.05, 0.05]) } } self.elbow_joint_prop = { 'type': 'sphere', 'center': self._init_elbow_point, 'radius': self._elbow_radius, 'bsdf': { 'type': 'ward', 'alphaU': 0.003, 'alphaV': 0.003, 'specularReflectance': Spectrum(0.01), 'diffuseReflectance': Spectrum([0.1, 0.1, 0.1]) } } self.forearm_endcap_prop = { 'type': 'sphere', 'center': self._init_forearm_start_point, 'radius': self._forearm_radius, 'bsdf': { 'type': 'ward', 'alphaU': 0.003, 'alphaV': 0.003, 'specularReflectance': Spectrum(0.01), 'diffuseReflectance': Spectrum([0.05, 0.05, 0.05]) } } self.forearm_prop = { 'type': 'cylinder', 'toWorld': self._init_forearm_toWorld, 'radius': self._forearm_radius, 'bsdf': { 'type': 'ward', 'alphaU': 0.003, 'alphaV': 0.003, 'specularReflectance': Spectrum(0.01), 'diffuseReflectance': Spectrum([0.05, 0.05, 0.05]) } } self.hand_prop = { 'type': 'sphere', 'center': self._init_hand_point, 'radius': self._forearm_radius, 'bsdf': { 'type': 'ward', 'alphaU': 0.003, 'alphaV': 0.003, 'specularReflectance': Spectrum(0.01), 'diffuseReflectance': Spectrum([0.05, 0.05, 0.05]) } }
def __add_quarter(self): scale = self.scene.active_view.scale radius = 12.13 * scale thickness = 0.875 * scale face_scale = Transform.scale(Vector(radius)) tail_offset = Transform.translate(Vector(0, 0, thickness)) head_offset = Transform.translate(Vector(0, 0, -thickness)) *\ Transform.scale(Vector(1.0, 1.0, -1.0)) bbox_diag = 0.5 * norm(self.transformed_bbox_max - self.transformed_bbox_min) custom_transform = Transform.translate( Vector(0.5, self.floor_height + radius + 0.01, -bbox_diag - 0.01)) head_texture = self.file_resolver.resolve("head.png") tail_texture = self.file_resolver.resolve("tail.png") side_texture = self.file_resolver.resolve("side.png") quarter_ring = self.plgr.create({ "type": "cylinder", "p0": Point(0.0, 0.0, thickness), "p1": Point(0.0, 0.0, -thickness), "radius": radius, "toWorld": custom_transform, "bsdf": { "type": "bumpmap", "texture": { "type": "scale", "scale": 0.01, "texture": { "type": "bitmap", "filename": side_texture, "gamma": 1.0, "uscale": 100.0, }, }, "bsdf": { "type": "roughconductor", "distribution": "ggx", "alpha": 0.5, "material": "Ni_palik" #"diffuseReflectance": Spectrum(0.5) } } }) head = self.plgr.create({ "type": "disk", "toWorld": custom_transform * head_offset * face_scale, "bsdf": { "type": "diffuse", "reflectance": { "type": "bitmap", "filename": head_texture } } }) tail = self.plgr.create({ "type": "disk", "toWorld": custom_transform * tail_offset * face_scale, "bsdf": { "type": "diffuse", "reflectance": { "type": "bitmap", "filename": tail_texture } } }) self.mitsuba_scene.addChild(quarter_ring) self.mitsuba_scene.addChild(head) self.mitsuba_scene.addChild(tail)
def __init__(self, ihp): # ihp is initial hip point self._thigh_radius = 1.5 self._thigh_length = 8.0 self._knee_radius = 1.5 self._calf_radius = 1.5 self._calf_length = 8.0 self._init_hip_point = ihp # == _init_thigh_start_point self._init_thigh_end_point = Point(ihp.x, ihp.y - self._thigh_length, ihp.z) self._init_thigh_toWorld = tf.translate( Vector(ihp.x, ihp.y - (self._thigh_length / 2), ihp.z)) * tf.scale( Vector(1, self._thigh_length, 1)) * tf.rotate( Vector(1, 0, 0), -90) * tf.translate(Vector(0, 0, -0.5)) self._init_knee_point = Point( ihp.x, ihp.y - (self._thigh_length + self._thigh_radius + self._knee_radius), ihp.z) self._init_calf_start_point = Point( ihp.x, ihp.y - (self._thigh_length + self._thigh_radius + self._knee_radius * 2 + self._calf_radius), ihp.z) self._init_foot_point = Point( ihp.x, ihp.y - (self._thigh_length + self._thigh_radius + self._knee_radius * 2 + self._calf_radius + self._calf_length), ihp.z) # == _init_calf_end_point self._init_calf_toWorld = tf.translate( Vector( ihp.x, ihp.y - (self._thigh_length + self._thigh_radius + self._knee_radius * 2 + self._calf_radius + self._calf_length / 2), ihp.z) ) * tf.scale(Vector(1, self._calf_length, 1)) * tf.rotate( Vector(1, 0, 0), -90) * tf.translate(Vector(0, 0, -0.5)) # local axes at hip self._hlocal_axes = { 'x': Vector(1, 0, 0), 'y': Vector(0, 1, 0), 'z': Vector(0, 0, 1) } # rotate angle of local axes at hip self._hlocal_axes_rotate_angle = {'pitch': 0, 'yaw': 0, 'roll': 0} self._hip_pitch = 0 self._hip_yaw = 0 self._hip_roll = 0 self._knee_angle = 0 self.hip_joint_prop = { 'type': 'sphere', 'center': self._init_hip_point, 'radius': self._thigh_radius, 'bsdf': { 'type': 'ward', 'alphaU': 0.003, 'alphaV': 0.003, 'specularReflectance': Spectrum(0.01), 'diffuseReflectance': Spectrum([0.05, 0.05, 0.05]) } } self.thigh_prop = { 'type': 'cylinder', 'toWorld': self._init_thigh_toWorld, 'radius': self._thigh_radius, 'bsdf': { 'type': 'ward', 'alphaU': 0.003, 'alphaV': 0.003, 'specularReflectance': Spectrum(0.01), 'diffuseReflectance': Spectrum([0.05, 0.05, 0.05]) } } self.thigh_endcap_prop = { 'type': 'sphere', 'center': self._init_thigh_end_point, 'radius': self._thigh_radius, 'bsdf': { 'type': 'ward', 'alphaU': 0.003, 'alphaV': 0.003, 'specularReflectance': Spectrum(0.01), 'diffuseReflectance': Spectrum([0.05, 0.05, 0.05]) } } self.knee_joint_prop = { 'type': 'sphere', 'center': self._init_knee_point, 'radius': self._knee_radius, 'bsdf': { 'type': 'ward', 'alphaU': 0.003, 'alphaV': 0.003, 'specularReflectance': Spectrum(0.01), 'diffuseReflectance': Spectrum([0.1, 0.1, 0.1]) } } self.calf_endcap_prop = { 'type': 'sphere', 'center': self._init_calf_start_point, 'radius': self._calf_radius, 'bsdf': { 'type': 'ward', 'alphaU': 0.003, 'alphaV': 0.003, 'specularReflectance': Spectrum(0.01), 'diffuseReflectance': Spectrum([0.05, 0.05, 0.05]) } } self.calf_prop = { 'type': 'cylinder', 'toWorld': self._init_calf_toWorld, 'radius': self._calf_radius, 'bsdf': { 'type': 'ward', 'alphaU': 0.003, 'alphaV': 0.003, 'specularReflectance': Spectrum(0.01), 'diffuseReflectance': Spectrum([0.05, 0.05, 0.05]) } } self.foot_prop = { 'type': 'sphere', 'center': self._init_foot_point, 'radius': self._calf_radius, 'bsdf': { 'type': 'ward', 'alphaU': 0.003, 'alphaV': 0.003, 'specularReflectance': Spectrum(0.01), 'diffuseReflectance': Spectrum([0.05, 0.05, 0.05]) } }
def __init__(self, isp): # isp is initial shoulder point self._upperarm_radius = 1.0 self._upperarm_length = 6.0 self._elbow_radius = 1.0 self._forearm_radius = 1.0 self._forearm_length = 6.0 self._init_shoulder_point = isp # == _init_upperarm_start_point self._init_upperarm_end_point = Point(isp.x, isp.y-self._upperarm_length, isp.z) self._init_upperarm_toWorld = tf.translate(Vector(isp.x, isp.y-(self._upperarm_length/2), isp.z)) * tf.scale(Vector(1, self._upperarm_length, 1)) * tf.rotate(Vector(1, 0, 0), -90) * tf.translate(Vector(0, 0, -0.5)) self._init_elbow_point = Point(isp.x, isp.y-(self._upperarm_length+self._upperarm_radius+self._elbow_radius), isp.z) self._init_forearm_start_point = Point(isp.x, isp.y-(self._upperarm_length+self._upperarm_radius+self._elbow_radius*2+self._forearm_radius), isp.z) self._init_hand_point = Point(isp.x, isp.y-(self._upperarm_length+self._upperarm_radius+self._elbow_radius*2+self._forearm_radius+self._forearm_length), isp.z) # == _init_forearm_end_point self._init_forearm_toWorld = tf.translate(Vector(isp.x, isp.y-(self._upperarm_length+self._upperarm_radius+self._elbow_radius*2+self._forearm_radius+self._forearm_length/2), isp.z)) * tf.scale(Vector(1, self._forearm_length, 1)) * tf.rotate(Vector(1, 0, 0), -90) * tf.translate(Vector(0, 0, -0.5)) # local axes at shoulder self._slocal_axes = { 'x' : Vector(1, 0, 0), 'y' : Vector(0, 1, 0), 'z' : Vector(0, 0, 1) } # rotate angle of local axes at shoulder self._slocal_axes_rotate_angle = { 'pitch' : 0, 'yaw' : 0, 'roll' : 0 } self._shoulder_pitch = 0 self._shoulder_yaw = 0 self._shoulder_roll = 0 self._elbow_angle = 0 self.shoulder_joint_prop = { 'type' : 'sphere', 'center' : self._init_shoulder_point, 'radius' : self._upperarm_radius, 'bsdf' : { 'type' : 'ward', 'alphaU' : 0.003, 'alphaV' : 0.003, 'specularReflectance' : Spectrum(0.01), 'diffuseReflectance' : Spectrum([0.05, 0.05, 0.05]) } } self.upperarm_prop = { 'type' : 'cylinder', 'toWorld': self._init_upperarm_toWorld, 'radius' : self._upperarm_radius, 'bsdf' : { 'type' : 'ward', 'alphaU' : 0.003, 'alphaV' : 0.003, 'specularReflectance' : Spectrum(0.01), 'diffuseReflectance' : Spectrum([0.05, 0.05, 0.05]) } } self.upperarm_endcap_prop = { 'type' : 'sphere', 'center' : self._init_upperarm_end_point, 'radius' : self._upperarm_radius, 'bsdf' : { 'type' : 'ward', 'alphaU' : 0.003, 'alphaV' : 0.003, 'specularReflectance' : Spectrum(0.01), 'diffuseReflectance' : Spectrum([0.05, 0.05, 0.05]) } } self.elbow_joint_prop = { 'type' : 'sphere', 'center' : self._init_elbow_point, 'radius' : self._elbow_radius, 'bsdf' : { 'type' : 'ward', 'alphaU' : 0.003, 'alphaV' : 0.003, 'specularReflectance' : Spectrum(0.01), 'diffuseReflectance' : Spectrum([0.1, 0.1, 0.1]) } } self.forearm_endcap_prop = { 'type' : 'sphere', 'center' : self._init_forearm_start_point, 'radius' : self._forearm_radius, 'bsdf' : { 'type' : 'ward', 'alphaU' : 0.003, 'alphaV' : 0.003, 'specularReflectance' : Spectrum(0.01), 'diffuseReflectance' : Spectrum([0.05, 0.05, 0.05]) } } self.forearm_prop = { 'type' : 'cylinder', 'toWorld' : self._init_forearm_toWorld, 'radius' : self._forearm_radius, 'bsdf' : { 'type' : 'ward', 'alphaU' : 0.003, 'alphaV' : 0.003, 'specularReflectance' : Spectrum(0.01), 'diffuseReflectance' : Spectrum([0.05, 0.05, 0.05]) } } self.hand_prop = { 'type' : 'sphere', 'center' : self._init_hand_point, 'radius' : self._forearm_radius, 'bsdf' : { 'type' : 'ward', 'alphaU' : 0.003, 'alphaV' : 0.003, 'specularReflectance' : Spectrum(0.01), 'diffuseReflectance' : Spectrum([0.05, 0.05, 0.05]) } }
def __init__(self, ihp): # ihp is initial hip point self._thigh_radius = 1.5 self._thigh_length = 8.0 self._knee_radius = 1.5 self._calf_radius = 1.5 self._calf_length = 8.0 self._init_hip_point = ihp # == _init_thigh_start_point self._init_thigh_end_point = Point(ihp.x, ihp.y-self._thigh_length, ihp.z) self._init_thigh_toWorld = tf.translate(Vector(ihp.x, ihp.y-(self._thigh_length/2), ihp.z)) * tf.scale(Vector(1, self._thigh_length, 1)) * tf.rotate(Vector(1, 0, 0), -90) * tf.translate(Vector(0, 0, -0.5)) self._init_knee_point = Point(ihp.x, ihp.y-(self._thigh_length+self._thigh_radius+self._knee_radius), ihp.z) self._init_calf_start_point = Point(ihp.x, ihp.y-(self._thigh_length+self._thigh_radius+self._knee_radius*2+self._calf_radius), ihp.z) self._init_foot_point = Point(ihp.x, ihp.y-(self._thigh_length+self._thigh_radius+self._knee_radius*2+self._calf_radius+self._calf_length), ihp.z) # == _init_calf_end_point self._init_calf_toWorld = tf.translate(Vector(ihp.x, ihp.y-(self._thigh_length+self._thigh_radius+self._knee_radius*2+self._calf_radius+self._calf_length/2), ihp.z)) * tf.scale(Vector(1, self._calf_length, 1)) * tf.rotate(Vector(1, 0, 0), -90) * tf.translate(Vector(0, 0, -0.5)) # local axes at hip self._hlocal_axes = { 'x' : Vector(1, 0, 0), 'y' : Vector(0, 1, 0), 'z' : Vector(0, 0, 1) } # rotate angle of local axes at hip self._hlocal_axes_rotate_angle = { 'pitch' : 0, 'yaw' : 0, 'roll' : 0 } self._hip_pitch = 0 self._hip_yaw = 0 self._hip_roll = 0 self._knee_angle = 0 self.hip_joint_prop = { 'type' : 'sphere', 'center' : self._init_hip_point, 'radius' : self._thigh_radius , 'bsdf' : { 'type' : 'ward', 'alphaU' : 0.003, 'alphaV' : 0.003, 'specularReflectance' : Spectrum(0.01), 'diffuseReflectance' : Spectrum([0.05, 0.05, 0.05]) } } self.thigh_prop = { 'type' : 'cylinder', 'toWorld': self._init_thigh_toWorld, 'radius' : self._thigh_radius, 'bsdf' : { 'type' : 'ward', 'alphaU' : 0.003, 'alphaV' : 0.003, 'specularReflectance' : Spectrum(0.01), 'diffuseReflectance' : Spectrum([0.05, 0.05, 0.05]) } } self.thigh_endcap_prop = { 'type' : 'sphere', 'center' : self._init_thigh_end_point, 'radius' : self._thigh_radius, 'bsdf' : { 'type' : 'ward', 'alphaU' : 0.003, 'alphaV' : 0.003, 'specularReflectance' : Spectrum(0.01), 'diffuseReflectance' : Spectrum([0.05, 0.05, 0.05]) } } self.knee_joint_prop = { 'type' : 'sphere', 'center' : self._init_knee_point, 'radius' : self._knee_radius, 'bsdf' : { 'type' : 'ward', 'alphaU' : 0.003, 'alphaV' : 0.003, 'specularReflectance' : Spectrum(0.01), 'diffuseReflectance' : Spectrum([0.1, 0.1, 0.1]) } } self.calf_endcap_prop = { 'type' : 'sphere', 'center' : self._init_calf_start_point, 'radius' : self._calf_radius, 'bsdf' : { 'type' : 'ward', 'alphaU' : 0.003, 'alphaV' : 0.003, 'specularReflectance' : Spectrum(0.01), 'diffuseReflectance' : Spectrum([0.05, 0.05, 0.05]) } } self.calf_prop = { 'type' : 'cylinder', 'toWorld' : self._init_calf_toWorld, 'radius' : self._calf_radius, 'bsdf' : { 'type' : 'ward', 'alphaU' : 0.003, 'alphaV' : 0.003, 'specularReflectance' : Spectrum(0.01), 'diffuseReflectance' : Spectrum([0.05, 0.05, 0.05]) } } self.foot_prop = { 'type' : 'sphere', 'center' : self._init_foot_point, 'radius' : self._calf_radius, 'bsdf' : { 'type' : 'ward', 'alphaU' : 0.003, 'alphaV' : 0.003, 'specularReflectance' : Spectrum(0.01), 'diffuseReflectance' : Spectrum([0.05, 0.05, 0.05]) } }