Exemplo n.º 1
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])
            }
        }
Exemplo n.º 2
0
    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
Exemplo n.º 3
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)
Exemplo n.º 4
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
Exemplo n.º 5
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])
            }
        }
Exemplo n.º 6
0
            def transform_lookAt(self, origin, target, up, scale=None):
                # Blender is Z up but Mitsuba is Y up, convert the lookAt
                transform = Transform.lookAt(
                    Point(origin[0], origin[2], -origin[1]),
                    Point(target[0], target[2], -target[1]),
                    Vector(up[0], up[2], -up[1]))

                if scale is not None:
                    transform *= Transform.scale(Vector(scale, scale, 1))

                return transform
Exemplo n.º 7
0
            def transform_lookAt(self, origin, target, up, scale=None):
                # Blender is Z up but Mitsuba is Y up, convert the lookAt
                transform = Transform.lookAt(
                    Point(origin[0], origin[2], -origin[1]),
                    Point(target[0], target[2], -target[1]),
                    Vector(up[0], up[2], -up[1])
                )

                if scale is not None:
                    transform *= Transform.scale(Vector(scale, scale, 1))

                return transform
Exemplo n.º 8
0
def convert_meshlab2mitsuba_camera(camera_def: dict) -> Transform:
    """
    Takes a meshlab camera dict (usually loaded from a meshlab xml file) and turns it into a valid mitsuba Transform
    which can then be applied to a sensor
    :param camera_def: The camera def dict, containing at least keys RotationMatrix and TranslationVector
    :return: A mitsuba transform constructed from the given values
    """
    # Meshlab camera matrix is transposed
    matrix = Matrix4x4([
        float(elem) for elem in camera_def['RotationMatrix'].split(' ')[:16]
    ]).transpose()

    # Add translation vector
    translation = [
        -float(elem) for elem in camera_def['TranslationVector'].split(' ')
    ]
    for i in range(3):
        matrix[i, 3] = translation[i]

    # Make Mitsuba transform and flip rotation signs (y is not flipped, otherwise resulting image will be flipped vertically)
    transform = Transform(matrix)
    transform *= transform.scale(Vector3(-1, 1, -1))

    return transform
Exemplo n.º 9
0
    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)
Exemplo n.º 10
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])
                }
            }
Exemplo n.º 11
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])
            }
        }
Exemplo n.º 12
0
def do_simulation_multiangle_seq(seqname):
    currdir = os.path.split(os.path.realpath(__file__))[0]
    sys.path.append(currdir + '/bin/rt/' + current_rt_program + '/python/2.7/')
    os.environ['PATH'] = currdir + '/bin/rt/' + current_rt_program + os.pathsep + os.environ['PATH']
    import mitsuba
    from mitsuba.core import Vector, Point, Ray, Thread, Scheduler, LocalWorker, PluginManager, Transform
    from mitsuba.render import SceneHandler
    from mitsuba.render import RenderQueue, RenderJob
    from mitsuba.render import Scene
    import multiprocessing

    scheduler = Scheduler.getInstance()
    for i in range(0, multiprocessing.cpu_count()):
        scheduler.registerWorker(LocalWorker(i, 'wrk%i' % i))
    scheduler.start()


    scene_path = session.get_scenefile_path()
    fileResolver = Thread.getThread().getFileResolver()
    fileResolver.appendPath(str(scene_path))
    scene = SceneHandler.loadScene(fileResolver.resolve(
        str(os.path.join(session.get_scenefile_path(), main_scene_xml_file))))
    scene.configure()
    scene.initialize()
    queue = RenderQueue()
    sceneResID = scheduler.registerResource(scene)
    bsphere = scene.getKDTree().getAABB().getBSphere()
    radius = bsphere.radius
    targetx, targety, targetz = bsphere.center[0], bsphere.center[1], bsphere.center[2]
    f = open(seqname + ".conf", 'r')
    params = json.load(f)
    obs_azimuth = params['seq1']['obs_azimuth']
    obs_zenith = params['seq2']['obs_zenith']
    cfgfile = session.get_config_file()
    f = open(cfgfile, 'r')
    cfg = json.load(f)
    viewR = cfg["sensor"]["obs_R"]
    mode = cfg["sensor"]["film_type"]
    azi_arr = map(lambda x: float(x), obs_azimuth.strip().split(":")[1].split(","))
    zeni_arr = map(lambda x: float(x), obs_zenith.strip().split(":")[1].split(","))
    seq_header = multi_file_prefix + "_" + seqname
    index = 0
    for azi in azi_arr:
        for zeni in zeni_arr:
            distFile = os.path.join(session.get_output_dir(),
                                    seq_header + ("_VA_%.2f" % azi).replace(".", "_") + ("_VZ_%.2f" % zeni).replace(".", "_"))
            newScene = Scene(scene)
            pmgr = PluginManager.getInstance()
            newSensor = pmgr.createObject(scene.getSensor().getProperties())
            theta = zeni / 180.0 * math.pi
            phi = (azi - 90) / 180.0 * math.pi
            scale_x = radius
            scale_z = radius
            toWorld = Transform.lookAt(
                Point(targetx - viewR * math.sin(theta) * math.cos(phi), targety + viewR * math.cos(theta),
                      targetz - viewR * math.sin(theta) * math.sin(phi)),  # original
                Point(targetx, targety, targetz),  # target
                Vector(0, 0, 1)  # up
            ) * Transform.scale(
                Vector(scale_x, scale_z, 1)  # 视场大小
            )
            newSensor.setWorldTransform(toWorld)
            newFilm = pmgr.createObject(scene.getFilm().getProperties())
            newFilm.configure()
            newSensor.addChild(newFilm)
            newSensor.configure()
            newScene.addSensor(newSensor)
            newScene.setSensor(newSensor)
            newScene.setSampler(scene.getSampler())
            newScene.setDestinationFile(str(distFile))
            job = RenderJob('Simulation Job' + "VA_"+str(azi)+"_VZ_"+str(zeni), newScene, queue, sceneResID)
            job.start()
        queue.waitLeft(0)
        queue.join()
    # handle npy
    if mode == "spectrum" and (output_format not in ("npy", "NPY")):
        for azi in azi_arr:
            for zeni in zeni_arr:
                distFile = os.path.join(session.get_output_dir(),
                                        seq_header + ("_VA_%.2f" % azi).replace(".", "_") + ("_VZ_%.2f" % zeni).replace(
                                            ".", "_"))
                data = np.load(distFile + ".npy")
                bandlist = cfg["sensor"]["bands"].split(",")
                RasterHelper.saveToHdr_no_transform(data, distFile, bandlist, output_format)
                os.remove(distFile + ".npy")
Exemplo n.º 13
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])
            }
        }
Exemplo n.º 14
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])
                }
            }
Exemplo n.º 15
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])
                }
            }