Exemple #1
0
    def __init__(self, name, typeName, minVal, maxVal, defaultVal,
                 description):
        self.name = name
        if typeName == "float":
            self.propType = PropertyTypeFloat(minVal, maxVal)
        else:
            print "Unrecognized Type:", typeName

        self.description = description.strip()
        self.defaultValue = defaultVal
        self.values = [self.defaultValue for i in xrange(8)]
        self.curve = NurbsCurve()
        self.curve.setOrder(3)
        self.pta = self.propType.getPTAType().emptyArray(1)
class DayProperty:

    """ Stores a time of day property, including name, description, type,
    min/max and default value """

    def __init__(self, name, typeName, minVal, maxVal, defaultVal, description):
        self.name = name
        if typeName == "float":
            self.propType = PropertyTypeFloat(minVal, maxVal)
        else:
            print "Unrecognized Type:", typeName

        self.description = description.strip()
        self.defaultValue = defaultVal
        self.values = [self.defaultValue for i in xrange(8)]
        self.curve = NurbsCurve()
        self.curve.setOrder(3)
        self.pta = self.propType.getPTAType().emptyArray(1)

    def getPTA(self):
        return self.pta       

    def setValue(self, index, val):
        self.values[index] = round(val, 5)

    def recompute(self):
        """ Recomputes the NURBS Curve for this property """
        self.curve.removeAllCvs()

        # Pad, to make 00:00 match with 24:00
        # Thanks to rdb for finding a bug here
        padIndices = [5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2]

        paddedValues = [self.values[i] for i in padIndices]

        for index, val in enumerate(paddedValues):
            self.curve.appendCv(Vec3(index, val, 0.0))

        self.curve.recompute()

    def getInterpolatedValue(self, pos):
        tmp = Vec3(0)
        self.curve.getPoint(pos * 8.0 + 2.5, tmp)
        return tmp.y
Exemple #3
0
class DayProperty:
    """ Stores a time of day property, including name, description, type,
    min/max and default value """
    def __init__(self, name, typeName, minVal, maxVal, defaultVal,
                 description):
        self.name = name
        if typeName == "float":
            self.propType = PropertyTypeFloat(minVal, maxVal)
        else:
            print "Unrecognized Type:", typeName

        self.description = description.strip()
        self.defaultValue = defaultVal
        self.values = [self.defaultValue for i in xrange(8)]
        self.curve = NurbsCurve()
        self.curve.setOrder(3)
        self.pta = self.propType.getPTAType().emptyArray(1)

    def getPTA(self):
        return self.pta

    def setValue(self, index, val):
        self.values[index] = round(val, 5)

    def recompute(self):
        """ Recomputes the NURBS Curve for this property """
        self.curve.removeAllCvs()

        # Pad, to make 00:00 match with 24:00
        # Thanks to rdb for finding a bug here
        padIndices = [5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2]

        paddedValues = [self.values[i] for i in padIndices]

        for index, val in enumerate(paddedValues):
            self.curve.appendCv(Vec3(index, val, 0.0))

        self.curve.recompute()

    def getInterpolatedValue(self, pos):
        tmp = Vec3(0)
        self.curve.getPoint(pos * 8.0 + 2.5, tmp)
        return tmp.y
    def __init__(self, name, typeName, minVal, maxVal, defaultVal, description):
        self.name = name
        if typeName == "float":
            self.propType = PropertyTypeFloat(minVal, maxVal)
        else:
            print "Unrecognized Type:", typeName

        self.description = description.strip()
        self.defaultValue = defaultVal
        self.values = [self.defaultValue for i in xrange(8)]
        self.curve = NurbsCurve()
        self.curve.setOrder(3)
        self.pta = self.propType.getPTAType().emptyArray(1)
    def create_node(self):
        node = NurbsCurve()

        for point in self.points:
            node.append_cv(point)

        for i, knot in enumerate(self.knots):
            node.set_knot(i, knot)

        return node