Ejemplo n.º 1
0
    def makeScene(self):

        script = Gaffer.ScriptNode()
        script["cube"] = GafferScene.Cube()
        script["cube"]["sets"].setValue("geometry")

        animY = Gaffer.Animation.acquire(
            script["cube"]["transform"]["translate"]["y"])
        animY.addKey(
            Gaffer.Animation.Key(0 / 24.0, 0, Gaffer.Animation.Type.Step))
        animY.addKey(
            Gaffer.Animation.Key(1 / 24.0, 1, Gaffer.Animation.Type.Step))
        animY.addKey(
            Gaffer.Animation.Key(2 / 24.0, 2, Gaffer.Animation.Type.Step))

        animX = Gaffer.Animation.acquire(
            script["cube"]["transform"]["translate"]["x"])
        animX.addKey(
            Gaffer.Animation.Key(2 / 24.0, 0, Gaffer.Animation.Type.Step))
        animX.addKey(
            Gaffer.Animation.Key(3 / 24.0, 1, Gaffer.Animation.Type.Step))
        animX.addKey(
            Gaffer.Animation.Key(4 / 24.0, 2, Gaffer.Animation.Type.Step))

        script["sphere"] = GafferScene.Sphere()
        script["sphere"]["sets"].setValue("geometry")
        script["parent"] = GafferScene.Parent()
        script["parent"]["in"].setInput(script["cube"]["out"])
        script["parent"]["child"][0].setInput(script["sphere"]["out"])
        script["cubeFilter"] = GafferScene.PathFilter()
        script["cubeFilter"]["paths"].setValue(
            IECore.StringVectorData(["/cube"]))
        script["parent"]["filter"].setInput(script["cubeFilter"]["out"])

        script["camera"] = GafferScene.Camera()
        script["camera"]["sets"].setValue("cameras")
        script["camera"]["transform"]["translate"]["y"].setValue(0.5)
        camAnimZ = Gaffer.Animation.acquire(
            script["camera"]["transform"]["translate"]["z"])
        camAnimZ.addKey(
            Gaffer.Animation.Key(0 / 24.0, 5, Gaffer.Animation.Type.Linear))
        camAnimZ.addKey(
            Gaffer.Animation.Key(4 / 24.0, 10, Gaffer.Animation.Type.Linear))

        script["light"] = GafferSceneTest.TestLight()
        script["light"]["sets"].setValue("lights")

        script["group"] = GafferScene.Group()
        script["group"]["in"][0].setInput(script["parent"]["out"])
        script["group"]["in"][1].setInput(script["camera"]["out"])
        script["group"]["in"][2].setInput(script["light"]["out"])

        script["motion"] = GafferScene.MotionPath()
        script["motion"]["in"].setInput(script["group"]["out"])
        script["motionFilter"] = GafferScene.PathFilter()
        script["motionFilter"]["paths"].setValue(
            IECore.StringVectorData(["/group/cube"]))
        script["motion"]["filter"].setInput(script["motionFilter"]["out"])
        script["motion"]["start"]["frame"].setValue(0)
        script["motion"]["end"]["frame"].setValue(4)

        script.context().setFrame(0)

        cubeMotionP = IECore.V3fVectorData([
            imath.V3f(0, 0, 0),
            imath.V3f(0, 1, 0),
            imath.V3f(0, 2, 0),
            imath.V3f(1, 2, 0),
            imath.V3f(2, 2, 0),
        ], IECore.GeometricData.Interpretation.Point)

        return script, cubeMotionP