Пример #1
0
    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']
Пример #2
0
    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
Пример #3
0
    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']
Пример #4
0
    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']
Пример #5
0
    def set_slocal_rotate_angle(self, gpitch, gyaw, groll):
        self._slocal_axes_rotate_angle['pitch'] = gpitch
        self._slocal_axes_rotate_angle['yaw'] = gyaw
        self._slocal_axes_rotate_angle['roll'] = groll
        rotation = tf.rotate(Vector(1, 0, 0), gpitch) * tf.rotate(Vector(0, 1, 0), gyaw) * tf.rotate(Vector(0, 0, 1), groll)
        self._slocal_axes['x'] = rotation * self._slocal_axes['x'] 
        self._slocal_axes['y'] = rotation * self._slocal_axes['y'] 
        self._slocal_axes['z'] = rotation * self._slocal_axes['z']

        self.set_joint_angles(self._shoulder_pitch, self._shoulder_yaw, self._shoulder_yaw, self._elbow_angle)

        return self._slocal_axes
Пример #6
0
    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])
            }
        }
Пример #7
0
    def set_slocal_rotate_angle(self, gpitch, gyaw, groll):
        self._slocal_axes_rotate_angle['pitch'] = gpitch
        self._slocal_axes_rotate_angle['yaw'] = gyaw
        self._slocal_axes_rotate_angle['roll'] = groll
        rotation = tf.rotate(Vector(1, 0, 0), gpitch) * tf.rotate(
            Vector(0, 1, 0), gyaw) * tf.rotate(Vector(0, 0, 1), groll)
        self._slocal_axes['x'] = rotation * self._slocal_axes['x']
        self._slocal_axes['y'] = rotation * self._slocal_axes['y']
        self._slocal_axes['z'] = rotation * self._slocal_axes['z']

        self.set_joint_angles(self._shoulder_pitch, self._shoulder_yaw,
                              self._shoulder_yaw, self._elbow_angle)

        return self._slocal_axes
Пример #8
0
    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])
            }
        }
Пример #9
0
    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)
Пример #10
0
def create_trajectory_on_bbsphere(bbox,
                                  initial_positioning_vector: Vector3,
                                  rotation_around: Vector3,
                                  num_cameras: int,
                                  radius_multiplier: float,
                                  tilt: Transform = None) -> List[Transform]:
    """
    Creates an interpolated trajectory on the bounding sphere of a scene/object
    :param bbox: The bounding box of the object/scene to render
    :param initial_positioning_vector: Controls where to position the camera initially
    :param rotation_around: Specify axis to rotate camera around
    :param num_cameras: Number of cameras to generate
    :param radius_multiplier: Cameras will be placed at distance multiplier * bbsphere radius
    :param tilt: Additional transformation meant to tilt the camera a bit
    :return: List with generated transforms
    """
    transforms = []

    step_angle = 360. / float(num_cameras)
    for camera_idx in range(num_cameras):
        transform = create_transform_on_bbsphere(
            bbox, radius_multiplier,
            Transform.rotate(rotation_around, step_angle * camera_idx) * tilt *
            initial_positioning_vector)
        transforms.append(transform)

    return transforms
Пример #11
0
    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']
Пример #12
0
def main(args):
    input_filepaths = [Path(elem) for elem in args.input]
    output_path = Path(args.output)

    assert all([elem.is_file() for elem in input_filepaths])
    assert output_path.is_dir()

    bbox = get_pointcloud_bbox(load_from_ply(input_filepaths[0]))
    sensor_transform = cameras.create_transform_on_bbsphere(
        bbox,
        radius_multiplier=3.,
        positioning_vector=Vector3(0, -1, 1),
        tilt=Transform.rotate(util.axis_unit_vector('x'), -25.))
    sensor = cameras.create_sensor_from_transform(sensor_transform,
                                                  args.width,
                                                  args.height,
                                                  fov=45.,
                                                  num_samples=args.samples)
    render_pointclouds(zip(input_filepaths, cycle([output_path])), sensor,
                       args.radius, args.workers)
Пример #13
0
 def _create_xyz_rotation(self, pitch, yaw, roll):
     return tf.rotate(self._slocal_axes['x'], pitch) * tf.rotate(
         self._slocal_axes['y'], yaw) * tf.rotate(self._slocal_axes['z'],
                                                  roll)
Пример #14
0
    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])
                }
            }
Пример #15
0
    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])
                }
            }
Пример #16
0
    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])
                }
            }
Пример #17
0
 def _create_xyz_rotation(self, pitch, yaw, roll):
     return tf.rotate(self._slocal_axes['x'], pitch) * tf.rotate(self._slocal_axes['y'], yaw) * tf.rotate(self._slocal_axes['z'], roll)
Пример #18
0
    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])
            }
        }
Пример #19
0
    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])
            }
        }