Beispiel #1
0
        def process_joint( buffer ):
            """Processes a single joint statement
            """
            # split on whitespace
            values = buffer.split( None )

            # extract values
            # "boneName" parentIndex ( xPos yPos zPos ) ( xOrient yOrient zOrient )
            name, parent, nil, pos_x, pos_y, pos_z, nil, nil, quat_x, quat_y, quat_z, nil = values

            # remove quotes from name
            name = name[ 1:-1 ]

            # convert to appropriate type
            parent = int( parent )
            pos_x = float( pos_x )
            pos_y = float( pos_y )
            pos_z = float( pos_z )
            quat_x = float( quat_x )
            quat_y = float( quat_y )
            quat_z = float( quat_z )
            quat_w = compute_quaternion_w( quat_x, quat_y, quat_z )

            return (
                name,
                parent,
                (pos_x, pos_y, pos_z),
                (quat_x, quat_y, quat_z, quat_w)
                )
Beispiel #2
0
        def process_bone(buffer):
            """Processes a single bone statement
            """

            # split on whitespace
            values = buffer.split(None)

            # extract values
            # ( xPos yPos zPos ) ( xOrient yOrient zOrient )
            nil, pos_x, pos_y, pos_z, nil, nil, quat_x, quat_y, quat_z, nil = values

            # convert to appropriate type
            pos_x, pos_y, pos_z = float(pos_x), float(pos_y), float(pos_z)
            quat_x, quat_y, quat_z = float(quat_x), float(quat_y), float(quat_z)

            # calculate quaternion W value
            quat_w = compute_quaternion_w(quat_x, quat_y, quat_z)

            return ((pos_x, pos_y, pos_z), (quat_x, quat_y, quat_z, quat_w))
Beispiel #3
0
        def process_bone(buffer):
            """Processes a single bone statement
            """
            # split on whitespace
            values = buffer.split(None)

            # convert to float
            # do this to avoid issues converting None to float
            # when we add padding
            values = map(float, values)

            # extract values
            # xPos yPos zPos xOrient yOrient zOrient
            # because the values are optional, we need to use
            # our tuple extraction routine
            values = utils.extract_tuple(values, 6, None)
            pos_x, pos_y, pos_z, quat_x, quat_y, quat_z = values

            quat_w = None
            if quat_x and quat_y and quat_z:
                quat_w = compute_quaternion_w(quat_x, quat_y, quat_z)

            return ((pos_x, pos_y, pos_z), (quat_x, quat_y, quat_z, quat_w))