Turntable Example

This example cover how to create a turntable in Guerilla.

Setup

To start, we’ll add some primitives in our scene:

from guerilla import Document, Modifier
doc = Document()
doc.new(warn=False)
with Modifier() as mod:
  # add a sphere
  doc.loadfile('$(LIBRARY)/primitives/sphere.glocator')
  # add a cube
  doc.loadfile('$(LIBRARY)/primitives/cube.glocator')

Camera

First, let’s create the camera and animate it:

from guerilla import Modifier, Document, Node, command

with Modifier() as mod:
  doc = Document()

  # setup timerange
  doc.LastFrame.set(120)

  # create a camera
  camNode = Node.create('turntable_cam', 'Camera')

  # create a transform under camera node
  eulerNode = Node.create('xform', 'TransformEuler', parent=camNode)

  # connect camera and transform
  camNode.Transform.connect(eulerNode.Out)

  # animate the rotation of our transform node
  animNode = Node.create('anim', 'CurveFloat', parent=camNode)

  # connect stuff
  eulerNode.RY.connect(animNode.Out)
  animNode.In.connect(doc.Time)

  # use Guerilla autokey feature
  doc.Time.set(1)
  eulerNode.RY.set(0)
  doc.Time.set(120)
  eulerNode.RY.set(360)

  # let the camera view our object
  mod.select({camNode}, mode='replace')
  command.executebyshortname("Frame Camera")

Going further