Python
The Python plugin enables the use of Python as a scripting language within Tellusim applications. It leverages the Python binding to expose the Tellusim API to Python, allowing scripts to control and update the scene dynamically at runtime.
info
Python plugin can be embedded into GraphScript, NodeScript, or MaterialScript and used dynamically.
#include <system/python/include/TellusimPython.h>
Example
// Load Python script
Python python;
if(!python.load("main")) return false;
// Create scene using Python script
if(!python.run("create", scene)) return false;
// Update scene using Python script
if(!python.run("update", scene)) return false;
from tellusim import *
#
# create scene
#
def create(scene):
# get resources
graph = scene.getGraph('Graph')
box_mesh = scene.getObject('Box Mesh')
sphere_mesh = scene.getObject('Sphere Mesh')
cylinder_mesh = scene.getObject('Cylinder Mesh')
root_material = scene.getMaterial('Checkerboard Material')
# create scene
create_cylinder(0.2, 2.0, Matrix4x3d.translate(0.0, 0.0, 0.2) * Matrix4x3d.rotateX(90.0), density = 10.0)
create_box(Vector3f(8.0, 1.0, 0.3), Matrix4x3d.translate(0.0, 0.0, 0.6))
for z in range(0, 7):
create_cylinder(0.5, 1.0, Matrix4x3d.translate(-3.0 + z, 0.0, 2.0) * Matrix4x3d.rotateX(90.0))
create_box(Vector3f(1.0), Matrix4x3d.translate(-3.0, 0.0, 4.0)))
create_sphere(0.75, Matrix4x3d.translate(3.0, 0.0, 8.0), density = 10.0)
for x in range(0, 40):
for z in range(0, x + 1):
k = x * 0.17 + z * 0.13
create_box(Vector3f(0.5), Matrix4x3d.translate(Vector3d(x - z * 0.5 - 20.0, 16.0, z + 1.0) * 0.5))
for x in range(0, 20):
for z in range(0, x + 1):
k = x * 0.17 + z * 0.13
create_cylinder(0.25, 0.5, Matrix4x3d.translate(Vector3d(x - z * 0.5 - 10.0, 8.0, z + 1.0) * 0.5))