Beispiel #1
0
 def ruby(cls):
     """Return ruby material"""
     return Material(
         ambient=QVector3D(0.1745, 0.01175, 0.01175), 
         diffuse=QVector3D(0.61424, 0.04136, 0.04136), 
         specular=QVector3D(0.727811, 0.626959, 0.626959), 
         shininess=76.8)
Beispiel #2
0
def calc_hand_pos(model, finger_links, frames, bf):

    # グローバル行列算出
    _, _, _, global_4ds = create_matrix(model, finger_links, frames, bf)

    upper_pos = QVector3D()
    elbow_pos = QVector3D()
    finger_pos = QVector3D()

    logger.debug("--------------")
    for lidx, lbone in enumerate(reversed(finger_links)):
        logger.debug("frame: %s: lidx: %s, %s, %s", bf.frame, lidx, lbone.name,
                     global_4ds[lidx].toVector3D())

        if "上半身" == lbone.name:
            # 上半身固定
            upper_pos = global_4ds[lidx].toVector3D()

        if "ひじ" in lbone.name:
            elbow_pos = global_4ds[lidx].toVector3D()

        if lidx == len(finger_links) - 1:
            # 先端を指とする
            finger_pos = global_4ds[lidx].toVector3D()

    return upper_pos, elbow_pos, finger_pos
Beispiel #3
0
 def pearl(cls):
     """Return pearl material"""
     return Material(
         ambient=QVector3D(0.25, 0.20725, 0.20725), 
         diffuse=QVector3D(1, 0.829, 0.829), 
         specular=QVector3D(0.296648, 0.296648, 0.296648), 
         shininess=11.264)
Beispiel #4
0
 def jade(cls):
     """Return jade material"""
     return Material(
         ambient=QVector3D(0.135, 0.2225, 0.1575), 
         diffuse=QVector3D(0.54, 0.89, 0.63), 
         specular=QVector3D(0.316228, 0.316228, 0.316228), 
         shininess=12.8)
Beispiel #5
0
 def obsidian(cls):
     """Return obsidian material"""
     return Material(
         ambient=QVector3D(0.05375, 0.05, 0.06625), 
         diffuse=QVector3D(0.18275, 0.17, 0.22525), 
         specular=QVector3D(0.332741, 0.328634, 0.346435), 
         shininess=38.4)
Beispiel #6
0
 def gold(cls):
     """Return gold material"""
     return Material(
         ambient=QVector3D(0.24725, 0.1995, 0.0745), 
         diffuse=QVector3D(0.75164, 0.60648, 0.22648), 
         specular=QVector3D(0.628281, 0.555802, 0.366065), 
         shininess=51.2)
Beispiel #7
0
 def polishedGold(cls):
     """Return polished gold material"""
     return Material(
         ambient=QVector3D(0.24725, 0.2245, 0.0645), 
         diffuse=QVector3D(0.34615, 0.3143, 0.0903), 
         specular=QVector3D(0.797357, 0.723991, 0.208006), 
         shininess=83.2)
Beispiel #8
0
 def plasticCyan(cls):
     """Return cyan plastic material"""
     return Material(
         ambient=QVector3D(0.0, 0.0, 0.0), 
         diffuse=QVector3D(0.1, 0.35, 0.1), 
         specular=QVector3D(0.45, 0.55, 0.45), 
         shininess=32.0)
Beispiel #9
0
 def emerald(cls):
     """Return emerald material"""
     return Material(
         ambient=QVector3D(0.0215, 0.1745, 0.0215), 
         diffuse=QVector3D(0.07568, 0.61424, 0.07568), 
         specular=QVector3D(0.633, 0.727811, 0.633), 
         shininess=76.8)
Beispiel #10
0
 def copper(cls):
     """Return copper material"""
     return Material(
         ambient=QVector3D(0.19125, 0.0735, 0.0225), 
         diffuse=QVector3D(0.7038, 0.27048, 0.0828), 
         specular=QVector3D(0.256777, 0.137622, 0.086014), 
         shininess=12.8)
Beispiel #11
0
 def polishedCopper(cls):
     """Return polished copper material"""
     return Material(
         ambient=QVector3D(0.2295, 0.08825, 0.0275), 
         diffuse=QVector3D(0.5508, 0.2118, 0.066), 
         specular=QVector3D(0.580594, 0.223257, 0.0695701), 
         shininess=51.2)
Beispiel #12
0
 def chrome(cls):
     """Return chrome material"""
     return Material(
         ambient=QVector3D(0.25, 0.25, 0.25), 
         diffuse=QVector3D(0.4, 0.4, 0.4), 
         specular=QVector3D(0.774597, 0.774597, 0.774597), 
         shininess=76.8)
Beispiel #13
0
def set_groove(bone_frame_dic, bone_csv_file):

    # グルーブボーンがあるか
    is_groove = False
    # ボーンファイルを開く
    with open(bone_csv_file, "r",
              encoding=get_file_encoding(bone_csv_file)) as bf:
        reader = csv.reader(bf)

        for row in reader:
            if row[1] == "グルーブ" or row[2].lower() == "groove":
                is_groove = True
                break

    if is_groove:

        for n in range(len(bone_frame_dic["センター"])):
            # logger.debug("グルーブ移管 frame={0}".format(n))

            # グルーブがある場合、Y軸をグルーブに設定
            bone_frame_dic["グルーブ"][n].position = QVector3D(
                0, bone_frame_dic["センター"][n].position.y(), 0)
            bone_frame_dic["センター"][n].position = QVector3D(
                bone_frame_dic["センター"][n].position.x(), 0,
                bone_frame_dic["センター"][n].position.z())

    return is_groove
Beispiel #14
0
def add_axis(bounding_box, vertex_buf, index_buf):
    bb_min, bb_max = bounding_box

    start = QVector3D(bb_min)
    direction = bb_max - start
    start -= 0.1 * direction

    start_to_end_x = QVector3D(bb_max.x() - start.x(), 0, 0)
    start_to_end_y = QVector3D(0, bb_max.y() - start.y(), 0)
    start_to_end_z = QVector3D(0, 0, bb_max.z() - start.z())
    max_bb_len = max(start_to_end_x.length(), start_to_end_y.length(),
                     start_to_end_z.length())
    start_to_end_x = start_to_end_x.normalized() * max_bb_len * 0.5
    start_to_end_y = start_to_end_y.normalized() * max_bb_len * 0.5
    start_to_end_z = start_to_end_z.normalized() * max_bb_len * 0.5

    vertex_buf_stride = 3 + 3 + 2  # position, normal, tex_coord

    add_triangle_prism(start, start_to_end_x, start_to_end_y, 0.01,
                       [1.0, 0.0, 0.0], vertex_buf, vertex_buf_stride,
                       index_buf)
    add_triangle_prism(start, start_to_end_y, start_to_end_z, 0.01,
                       [0.0, 0.5, 0.0], vertex_buf, vertex_buf_stride,
                       index_buf)
    add_triangle_prism(start, start_to_end_z, start_to_end_x, 0.01,
                       [0.0, 0.0, 1.0], vertex_buf, vertex_buf_stride,
                       index_buf)

    return start.length()
Beispiel #15
0
 def plasticRed(cls):
     """Return red plastic material"""
     return Material(
         ambient=QVector3D(0.0, 0.0, 0.0), 
         diffuse=QVector3D(0.5, 0.0, 0.0), 
         specular=QVector3D(0.7, 0.6, 0.6), 
         shininess=32)
Beispiel #16
0
 def silver(cls):
     """Return silver material"""
     return Material(
         ambient=QVector3D(0.19225, 0.19225, 0.19225), 
         diffuse=QVector3D(0.50754, 0.50754, 0.50754), 
         specular=QVector3D(0.508273, 0.508273, 0.508273), 
         shininess=51.2)
Beispiel #17
0
    def quad(self, x1, y1, x2, y2, x3, y3, x4, y4):
        #print("quad inicio")
        self.vertices.append(QVector3D(x1, y1, -0.05))
        self.vertices.append(QVector3D(x2, y2, -0.05))
        self.vertices.append(QVector3D(x4, y4, -0.05))

        self.vertices.append(QVector3D(x3, y3, -0.05))
        self.vertices.append(QVector3D(x4, y4, -0.05))
        self.vertices.append(QVector3D(x2, y2, -0.05))

        n = QVector3D.normal(QVector3D(x2 - x1, y2 - y1, 0.0), QVector3D(x4 - x1, y4 - y1, 0.0))

        for i in range(6):
            self.normals.append(n)

        self.vertices.append(QVector3D(x4, y4, 0.05))
        self.vertices.append(QVector3D(x2, y2, 0.05))
        self.vertices.append(QVector3D(x1, y1, 0.05))

        self.vertices.append(QVector3D(x2, y2, 0.05))
        self.vertices.append(QVector3D(x4, y4, 0.05))
        self.vertices.append(QVector3D(x3, y3, 0.05))

        n = QVector3D.normal(QVector3D(x2 - x4, y2 - y4, 0.0), QVector3D(x1 - x4, y1 - y4, 0.0))

        for i in range(6):
            self.normals.append(n)
 def intersect(self, ray, t0=0, t1=10000):
     """ Given a ray p(t) = e + td and an implicit surface f(p) = 0.
         We can represent a sphere in vector form:
         (p−c)·(p−c)−R2 = 0.
         Any point p that satisfies this equation is on the sphere.
         plug in p(t) in previous equation yields:
         (e+td−c)·(e+td−c)−R2 = 0
         which can be rearranged as :
         (d·d)t2 +2d·(e−c)t+(e−c)·(e−c)−R2 =0.
         giving us a quadratic equation, for which we can solve for t
         :param ray:  a Ray to p(t) = e + td
         :return:
             False if the discriminant is negative
             True if discriminant is positive and there are two solution
     """
     ec = ray.e - self.c
     A = QVector3D.dotProduct(ray.d, ray.d)
     B = QVector3D.dotProduct(2 * ray.d, ec)
     C = QVector3D.dotProduct(ec, ec) - self.r * self.r
     discriminant = B * B - 4 * A * C
     if discriminant < EPSILON:
         return -1.0
     localt0 = (-B + math.sqrt(discriminant)) / 2 * A
     localt1 = (-B - math.sqrt(discriminant)) / 2 * A
     t = min(localt0, localt1)
     return min(t, t1)
Beispiel #19
0
    def computeGrid(self, scale=1):
        mainLine = [QVector3D(0, 0, 0), QVector3D(1, 0, 0)]
        T = QMatrix4x4()
        self._vertices = mainLine[:]
        numLines = 12
        for i in range(0, numLines - 1):
            self.vertices.append(T * mainLine[0])
            self.vertices.append(T * mainLine[1])
            T.translate(0.0, 0.0, 0.1)

        T.setToIdentity()
        T.translate(0.0, 0.0, 1.0)
        T.rotate(90, 0, 1, 0)
        for i in range(0, numLines - 1):
            self.vertices.append(T * mainLine[0])
            self.vertices.append(T * mainLine[1])
            T.translate(0.0, 0.0, 0.1)

        T.setToIdentity()
        T.scale(scale)
        for i in range(0, len(self.vertices)):
            self.vertices[i] = T * self.vertices[i]

        self._verticesIndices = [i for i in range(0, len(self.vertices))]
        self._textureCoords = [
            QVector3D(0.0, 0.0, 0.0) for i in range(0, len(self.vertices))
        ]
        self._normals = [
            QVector3D(0.0, 0.0, 0.0) for i in range(0, len(self.vertices))
        ]
Beispiel #20
0
 def get_real_2d_coords_from_theoretical_3d_coords(self, point: QVector3D):
     z = point.x()
     y = point.y()
     x = point.z()
     x_2 = -(x - z) * sqrt(3) / 2
     y_2 = -((x + z) / 2 - y)
     return self.get_real_coord(QPointF(x_2, y_2))
Beispiel #21
0
 def bronze(cls):
     """Return bronze material"""
     return Material(
         ambient=QVector3D(0.2125, 0.1275, 0.054), 
         diffuse=QVector3D(0.714, 0.4284, 0.18144), 
         specular=QVector3D(0.393548, 0.271906, 0.166721), 
         shininess=25.6)
Beispiel #22
0
 def polishedBronze(cls):
     """Return polished bronze material"""
     return Material(
         ambient=QVector3D(0.25, 0.148, 0.06475), 
         diffuse=QVector3D(0.4, 0.2368, 0.1036), 
         specular=QVector3D(0.774597, 0.458561, 0.200621), 
         shininess=76.8)
Beispiel #23
0
 def rubberBlack(cls):
     """Return black rubber material"""
     return Material(
         ambient=QVector3D(0.02, 0.02, 0.02), 
         diffuse=QVector3D(0.01, 0.01, 0.0), 
         specular=QVector3D(0.4, 0.4, 0.4), 
         shininess=10.0)
Beispiel #24
0
 def __init__(self, frame=0):
     self.name = ''
     self.format_name = ''
     self.frame = frame
     self.position = QVector3D(0, 0, 0)
     self.rotation = QQuaternion()
     self.org_position = QVector3D(0, 0, 0)
     self.org_rotation = QQuaternion()
     self.complement = [
         20, 20, 0, 0, 20, 20, 20, 20, 107, 107, 107, 107, 107, 107, 107,
         107, 20, 20, 20, 20, 20, 20, 20, 107, 107, 107, 107, 107, 107, 107,
         107, 0, 20, 20, 20, 20, 20, 20, 107, 107, 107, 107, 107, 107, 107,
         107, 0, 0, 20, 20, 20, 20, 20, 107, 107, 107, 107, 107, 107, 107,
         107, 0, 0, 0
     ]
     self.org_complement = [
         20, 20, 0, 0, 20, 20, 20, 20, 107, 107, 107, 107, 107, 107, 107,
         107, 20, 20, 20, 20, 20, 20, 20, 107, 107, 107, 107, 107, 107, 107,
         107, 0, 20, 20, 20, 20, 20, 20, 107, 107, 107, 107, 107, 107, 107,
         107, 0, 0, 20, 20, 20, 20, 20, 107, 107, 107, 107, 107, 107, 107,
         107, 0, 0, 0
     ]
     # 登録対象であるか否か
     self.key = False
     # VMD読み込み処理で読み込んだキーか
     self.read = False
     # 補間曲線の分割で追加したキーか
     self.split_complement = False
Beispiel #25
0
 def rubberCyan(cls):
     """Return cyan rubber material"""
     return Material(
         ambient=QVector3D(0.0, 0.05, 0.05), 
         diffuse=QVector3D(0.4, 0.5, 0.5), 
         specular=QVector3D(0.04, 0.7, 0.7), 
         shininess=10.0)
Beispiel #26
0
 def rubberWhite(cls):
     """Return white rubber material"""
     return Material(
         ambient=QVector3D(0.05, 0.05,0.05), 
         diffuse=QVector3D(0.5, 0.5, 0.5), 
         specular=QVector3D(0.7, 0.7, 0.7), 
         shininess=10.0)
Beispiel #27
0
 def turquoise(cls):
     """Return turquoise material"""
     return Material(
         ambient=QVector3D(0.1, 0.18725, 0.1745), 
         diffuse=QVector3D(0.396, 0.74151, 0.69102), 
         specular=QVector3D(0.297254, 0.30829, 0.306678), 
         shininess=12.8)
Beispiel #28
0
 def tin(cls):
     """Return tin material"""
     return Material(
         ambient=QVector3D(0.105882, 0.058824, 0.113725), 
         diffuse=QVector3D(0.427451, 0.470588, 0.541176), 
         specular=QVector3D(0.333333, 0.333333, 0.521569), 
         shininess=9.84615)
Beispiel #29
0
 def polishedSilver(cls):
     """Return polished silver material"""
     return Material(
         ambient=QVector3D(0.23125, 0.23125, 0.23125), 
         diffuse=QVector3D(0.2775, 0.2775, 0.2775), 
         specular=QVector3D(0.773911, 0.773911, 0.773911), 
         shininess=89.6)
Beispiel #30
0
 def intersect(self, ray):
     """Returns intersection if any"""
     tMin = -math.inf
     tMax = math.inf
     obb_xform = self.transform()
     obb_center = QVector3D(obb_xform[0, 3], obb_xform[1, 3], obb_xform[2,
                                                                        3])
     point = obb_center - ray.origin()
     for i in range(3):
         axis = QVector3D(obb_xform[0, i], obb_xform[1, i],
                          obb_xform[2, i]).normalized()
         half_length = QVector3D(obb_xform[i, 0], obb_xform[i, 1],
                                 obb_xform[i, 2]).length() / 2.0
         e = QVector3D.dotProduct(axis, point)
         f = QVector3D.dotProduct(axis, ray.direction())
         if abs(f) > 10E-6:
             t1 = (e + half_length * self._pickFactor) / f
             t2 = (e - half_length * self._pickFactor) / f
             if t1 > t2:
                 w = t1
                 t1 = t2
                 t2 = w
             if t1 > tMin:
                 tMin = t1
             if t2 < tMax:
                 tMax = t2
             if tMin > tMax:
                 return (False, math.inf)
             if tMax < 0:
                 return (False, math.inf)
         elif -e - half_length > 0.0 or -e + half_length < 0.0:
             return (False, math.inf)
     if tMin > 0:
         return (True, tMin)
     return (True, tMax)
Beispiel #31
0
 def brass(cls):
     """Return brass material"""
     return Material(
         ambient=QVector3D(0.329412, 0.223529, 0.027451), 
         diffuse=QVector3D(0.780392, 0.568627, 0.113725), 
         specular=QVector3D(0.992157, 0.941176, 0.807843), 
         shininess=27.89743616)
    def rotateUpDown(self, angle):
        """ Rotates camera up/down """
        axis = QVector3D.crossProduct(self.up, self.center - self.eye)

        transform = QMatrix4x4()
        transform.translate(self.center)
        transform.rotate(angle, axis)
        transform.translate(-self.center)

        self.eye = transform.map(self.eye)

        transform = QMatrix4x4()
        transform.rotate(angle, axis)
        self.up = transform.map(self.up)
Beispiel #33
0
    def extrude(self, x1, y1, x2, y2):
        #print("extrude inicio")
        self.vertices.append(QVector3D(x1, y1, +0.05))
        self.vertices.append(QVector3D(x2, y2, +0.05))
        self.vertices.append(QVector3D(x1, y1, -0.05))

        self.vertices.append(QVector3D(x2, y2, -0.05))
        self.vertices.append(QVector3D(x1, y1, -0.05))
        self.vertices.append(QVector3D(x2, y2, +0.05))

        n = QVector3D.normal(QVector3D(x2 - x1, y2 - y1, 0.0), QVector3D(0.0, 0.0, -0.1))

        for i in range(6):
            self.normals.append(n)
    def __init__(self):

        self.center = QVector3D(0.5, 0.5, 0.5)
        self.eye = QVector3D(0, 0, 3)

        lookDirection = (self.center - self.eye).normalized()
        self.up = QVector3D(0, 0, 1)
        self.up = (self.up - lookDirection * QVector3D.dotProduct(lookDirection, self.up)).normalized()

        self.clearColor = [0.3, 0.25, 0.35, 1.0]
        self.selectedLandscapeCell = (float("inf"), float("inf"))

        self.lightSourcePosition = QVector3D(1.5, 1.5, 2.7)
        self.lastMousePosition = QPoint()

        try:
            self.n, self.m, self.landscapeHeightsMatrix = self.loadLandscapeHeightsMatrix()
        except:
            self.n, self.m = 10, 10
            self.landscapeHeightsMatrix = self.generateLandscapeHeightsMatrix()
        self.generateWaterHeightsMatrix()