示例#1
0
    def recalculate_transform(self):
        """ Recalculate coordinates of nodes based on the cumulative transformation """
        bias_mat = wireframe.translationMatrix(*self.bias)
        rot_mat = wireframe.rotateMatrix(*self.view_angle)
        scale_mat = wireframe.scaleMatrix(*self.scale)

        self.tf_wireframe.nodes = (self.wireframe.nodes - self._center_half) @ \
                                   rot_mat @ scale_mat @ bias_mat
示例#2
0
def testScale():
    """ Example of how to scale a wireframe.
        Creates a cuboid and scales it by 2, centred on (100,150,200). """
    
    cuboid = shape.Cuboid((100,100,10), (20,30,40))
    cuboid.outputNodes()

    print "\n> Scale cuboid by 2, centred at (100,150,200)"
    cuboid.transform(wf.scaleMatrix(2, 100, 150, 200))
    cuboid.outputNodes()
示例#3
0
def testScale():
    """ Example of how to scale a wireframe.
        Creates a cuboid and scales it by 2, centred on (100,150,200). """

    cuboid = shape.Cuboid((100, 100, 10), (20, 30, 40))
    cuboid.outputNodes()

    print "\n> Scale cuboid by 2, centred at (100,150,200)"
    cuboid.transform(wf.scaleMatrix(2, 100, 150, 200))
    cuboid.outputNodes()
示例#4
0
def setup_viewer(viewer):
    if scene == "shark":
        viewer.addEffect(fx.DrawSpeedTween(1, 45, 1, 20))
        viewer.addWireframe('spin', obj.loadOBJ("shark.obj"))
        viewer.wireframes['spin'].transform(wf.scaleMatrix(150))
    elif scene == "text":
        viewer.addEffect(fx.DrawSpeedTween(1, 150, 1, 50))
        viewer.addWireframe('spin', obj.loadOBJ("text_test.obj"))
        viewer.wireframes['spin'].transform(wf.scaleMatrix(3))
        viewer.wireframes['spin'].transform(wf.rotateZMatrix(-np.pi))
        viewer.wireframes['spin'].transform(wf.rotateYMatrix(-np.pi))
    elif scene == "watchdogs":
        viewer.addEffect(fx.DrawSpeedTween(1, 70, 1, 10))
        viewer.addWireframe('spin', obj.loadOBJ("watchdogs.obj"))
        viewer.wireframes['spin'].transform(wf.scaleMatrix(3))
        viewer.wireframes['spin'].transform(wf.rotateZMatrix(-np.pi))
        viewer.wireframes['spin'].transform(wf.rotateYMatrix(-np.pi))
    elif scene == "milkey":
        viewer.addEffect(fx.MIDIModulator("milkey.uss"))
        viewer.addWireframe('head', shape.Spheroid((0,)*3, (150,)*3, resolution=5))
        viewer.addWireframe('left_ear', shape.Spheroid((0,)*3, (75,)*3, resolution=3))
        viewer.addWireframe('right_ear', shape.Spheroid((0,)*3, (75,)*3, resolution=3))
    elif scene == "cube":
        viewer.addEffect(fx.DrawSpeedTween(1, 250, 2, 50))
        viewer.addWireframe('spin', shape.Cuboid((0,)*3, (150,)*3))
    elif scene == "sphere":
        viewer.addEffect(fx.DrawSpeedTween(0.25, 130, 0.25, 20))
        viewer.addWireframe('spin', shape.Spheroid((0,)*3, (150,)*3))
    if scene != "milkey":
        viewer.centerWireframe("spin")
    else:
        viewer.centerWireframe("head")
        viewer.centerWireframe("left_ear")
        viewer.wireframes["left_ear"].transform(wf.translationMatrix(150, -150, 0))
        viewer.centerWireframe("right_ear")
        viewer.wireframes["right_ear"].transform(wf.translationMatrix(-150, -150, 0))
    viewer.key_to_function = {}
    viewer.object_update = object_update
示例#5
0
 def scaleAll(self, vector):
     for wireframe in self.wireframes.values():
         wireframe.transform(wf.scaleMatrix(vector[0], vector[1], vector[2]))
示例#6
0
 def scale(self, scale):
     """ Scale wireframes in all directions from the centre of the group. """
     
     scale_matrix = wf.scaleMatrix(scale, self.width/2, self.height/2, 0)
     self.transform(scale_matrix)
示例#7
0
    def scale(self, scale):
        """ Scale wireframes in all directions from the centre of the group. """

        scale_matrix = wf.scaleMatrix(scale, self.width / 2, self.height / 2,
                                      0)
        self.transform(scale_matrix)
 def scale(self, scale):
     """ Scale wireframes in all directions from the centre of the group. """
     (x, y, z) = self.findCentre()
     scale_matrix = wf.scaleMatrix(scale, x, y, z)
     self.transform(scale_matrix)