Created
October 20, 2016 18:59
-
-
Save est77/7c7a81a7b6f1944707d152ad123e5a57 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import appleseed as asr | |
mesh = asr.MeshObject("my_mesh", {}) | |
print mesh | |
# Vertices | |
v0 = asr.Vector3f([0.0, 0.0, 0.0]) | |
v1 = asr.Vector3f([1.0, 0.0, 0.0]) | |
v2 = asr.Vector3f([0.0, 0.0, 1.0]) | |
mesh.reserve_vertices(3) | |
mesh.push_vertex(v0) | |
mesh.push_vertex(v1) | |
mesh.push_vertex(v2) | |
print "Num vertices = ", mesh.get_vertex_count() | |
# Normals | |
n0 = asr.Vector3f([0.0, 1.0, 0.0]) | |
n1 = asr.Vector3f([0.0, 1.0, 0.0]) | |
n2 = asr.Vector3f([0.0, 1.0, 0.0]) | |
mesh.reserve_vertex_normals(3) | |
mesh.push_vertex_normal(n0) | |
mesh.push_vertex_normal(n1) | |
mesh.push_vertex_normal(n2) | |
print "Num normals = ", mesh.get_vertex_normal_count() | |
# uvs | |
uv0 = asr.Vector2f([0.0, 0.0]) | |
uv1 = asr.Vector2f([1.0, 0.0]) | |
uv2 = asr.Vector2f([0.0, 1.0]) | |
#mesh.reserve_tex_coors(3) | |
mesh.push_tex_coords(uv0) | |
mesh.push_tex_coords(uv1) | |
mesh.push_tex_coords(uv2) | |
print "Num UVs = ", mesh.get_vertex_normal_count() | |
# triangles | |
mesh.reserve_triangles(1) | |
tri = asr.Triangle() | |
# Vertex indices | |
tri.v0 = 0 | |
tri.v1 = 1 | |
tri.v2 = 2 | |
# Normal indices | |
tri.n0 = 0 | |
tri.n1 = 1 | |
tri.n2 = 2 | |
# UVs indices | |
tri.a0 = 0 | |
tri.a1 = 1 | |
tri.a2 = 2 | |
# Material index | |
tri.pa = 0 | |
mesh.push_triangle(tri) | |
print "Num triangles = ", mesh.get_triangle_count() | |
# Now, mesh can be passed to appleseed in the same way as the basic.py script |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment