Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
255 views
Kernel: Python 2

4 sphere example

from sage.all import * t = Tachyon(camera_center=(0,-4,1), xres = 800, yres = 600, raydepth = 12, aspectratio=.75, antialiasing = 4) t.light((0.02,0.012,0.001), 0.01, (1,0,0)) t.light((0,0,10), 0.01, (0,0,1)) t.texture('s', color = (.8,1,1), opacity = .9, specular = .95, diffuse = .3, ambient = 0.05) t.texture('p', color = (0,0,1), opacity = 1, specular = .2) t.sphere((-1,-.57735,-0.7071),1,'s') t.sphere((1,-.57735,-0.7071),1,'s') t.sphere((0,1.15465,-0.7071),1,'s') t.sphere((0,0,0.9259),1,'s') t.plane((0,0,-1.9259),(0,0,1),'p') t.show() # long time t.save('mesh/4spheres.png')

import pyparsing as pp coord = pp.Word(pp.nums+'+-.') vector = pp.Suppress(pp.Literal('V') + pp.Word(pp.nums)) + pp.Group(coord * 3) triangle = pp.Suppress(pp.Literal('TRI')) + pp.Group(vector * 3) + pp.Suppress(pp.Literal('Material_')+pp.Word(pp.nums)) meshfile = pp.Literal('BEGIN_SCENE').suppress() + pp.SkipTo(triangle).suppress() + pp.Group(pp.OneOrMore(triangle))
text = open('mesh/srb1.dat', 'r').read() triangles = meshfile.parseString(text).asList()[0]
tach = Tachyon(camera_center=(4.5,5.1,0), xres = 500, yres = 500, raydepth = 7, aspectratio=.75, antialiasing = 4) tach.light((0,0,50), 1, (1,1,1)) tach.texture('d', color = (0,0,0), opacity = 0, specular = 1, diffuse = 0, ambient = 0) tach.texture('p', color = (0.2,0.4,0.6), opacity = 1, specular = .18, ambient = 0.05) for tri in triangles: tach.triangle(tri[0], tri[1], tri[2], 'd') tach.plane((0,0,-1.9),(0,0,1),'p') tach.show() tach.save('mesh/diamond.png')