source: inundation/ga/storm_surge/pyvolution-parallel/faces_cone.py @ 1231

Last change on this file since 1231 was 1231, checked in by steve, 20 years ago

Added advection example for parallel testing

File size: 1013 bytes
Line 
1from visual import *
2# Example of use of faces object for building arbitrary shapes (here, a cone)
3# David Scherer July 2001
4
5f = frame()
6
7box( size=(0.5,0.5,0.5) )
8
9# Make a cone (smooth shading, no bottom, normals are not quite physical)
10
11N = 20
12
13model = faces( pos = zeros( (N*3,3), Float ), frame = f )
14
15t = arange(0,2*pi+2*pi/N,2*pi/N)
16
17# Vertex 0 of triangles
18model.pos[0::3, 0] = sin(t[:-1])
19model.pos[0::3, 2] = cos(t[:-1])
20
21# Vertex 1 of triangles
22model.pos[1::3, 0] = sin(t[1:])
23model.pos[1::3, 2] = cos(t[1:])
24
25# Vertex 2 of triangles (point of cone)
26model.pos[2::3, 1] = 2
27
28# All normals point outward in XZ... not quite right, but there is already a cone primitive :)
29model.normal = model.pos
30model.normal[2::3,0] = sin((t[:-1]+t[1:])/2)
31model.normal[2::3,1] = 0
32model.normal[2::3,2] = cos((t[:-1]+t[1:])/2)
33
34model.color = model.pos/2 + (0.5,0,0.5)
35
36model.color[0::3] = (1,1,1)   # show where the triangles are
37
38while 1:
39    rate(100)
40    f.rotate(angle=0.01)
Note: See TracBrowser for help on using the repository browser.