def main(filename): ti.init(ti.gpu) obj = tina.readobj(filename, scale='auto') scene = tina.Scene((1024, 768), maxfaces=len(obj['f']), smoothing=True) model = tina.MeshModel(obj) scene.add_object(model) gui = ti.GUI('mesh', scene.res, fast_gui=True) while gui.running: scene.input(gui) scene.render() gui.set_image(scene.img) gui.show()
import taichi as ti import numpy as np import tina ti.init(ti.opengl) engine = tina.Engine(texturing=True) camera = tina.Camera() img = ti.Vector.field(3, float, engine.res) lighting = tina.Lighting() material = tina.CookTorrance(basecolor=tina.Texture('assets/cloth.jpg'), ) shader = tina.Shader(img, lighting, material) obj = tina.readobj('assets/monkey.obj') verts = obj['v'][obj['f'][:, :, 0]] coors = obj['vt'][obj['f'][:, :, 1]] gui = ti.GUI('texture', engine.res, fast_gui=True) control = tina.Control(gui) while gui.running: control.get_camera(camera) engine.set_camera(camera) img.fill(0) engine.clear_depth() engine.set_face_verts(verts) engine.set_face_coors(coors)
import taichi as ti import tina ti.init(ti.gpu) verts, faces = tina.readobj('assets/monkey.obj', simple=True) scene = tina.Scene() mesh = tina.ConnectiveMesh() scene.add_object(mesh, tina.Classic()) mesh.set_vertices(verts) mesh.set_faces(faces) gui = ti.GUI() while gui.running: scene.input(gui) verts[100, 1] = ti.sin(gui.frame * 0.02) mesh.set_vertices(verts) scene.render() gui.set_image(scene.img) gui.show()
import taichi as ti import numpy as np import tina ti.init(ti.opengl) engine = tina.Engine(smoothing=True) camera = tina.Camera() img = ti.Vector.field(3, float, engine.res) lighting = tina.Lighting() material = tina.CookTorrance() shader = tina.Shader(img, lighting, material) obj = tina.readobj('assets/sphere.obj') verts = obj['v'][obj['f'][:, :, 0]] norms = obj['vn'][obj['f'][:, :, 2]] gui = ti.GUI('matball', engine.res) control = tina.Control(gui) metallic = gui.slider('metallic', 0.0, 1.0, 0.1) roughness = gui.slider('roughness', 0.0, 1.0, 0.1) specular = gui.slider('specular', 0.0, 1.0, 0.1) metallic.value = material.metallic[None] roughness.value = material.roughness[None] specular.value = material.specular[None] while gui.running:
import taichi as ti import numpy as np import tina ti.init(ti.gpu) scene = tina.PTScene() verts, faces = tina.readobj('assets/sphere.obj', simple=True) verts = verts[faces] model = tina.SimpleMesh() scene.add_object(model) scene.engine.skybox = tina.Atomsphere() scene.materials = [tina.Lambert(), tina.Lambert() * [0, 1, 0]] mtlids = np.zeros(verts.shape[0]) mtlids[3] = 1 mtlids[5] = 1 model.set_face_verts(verts) model.set_face_mtlids(mtlids) scene.update() scene.visualize()
import taichi as ti import numpy as np import tina import sys ti.init(ti.gpu) obj = tina.readobj(sys.argv[1], scale='auto') verts = obj['v'][obj['f'][:, :, 0]] norms = obj['vn'][obj['f'][:, :, 2]] engine = tina.Engine((1024, 768), maxfaces=len(verts), smoothing=True) camera = tina.Camera() img = ti.Vector.field(3, float, engine.res) shader = tina.SimpleShader(img) gui = ti.GUI('visualize', engine.res, fast_gui=True) control = tina.Control(gui) accum = tina.Accumator(engine.res) while gui.running: engine.randomize_bias(accum.count[None] <= 1) if control.get_camera(camera): accum.clear() engine.set_camera(camera) img.fill(0)