Created
June 25, 2014 12:49
-
-
Save tobspr/926870764d54d01d8169 to your computer and use it in GitHub Desktop.
This file contains 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
@classmethod | |
def simplifyGeom(self, geom, state): | |
print "Simplifying geom", geom | |
v1 = Vertex(Vec3(0, 0, 1), Vec3(0, 1, 0), Vec2(0, 1), Vec3(1,0,0)) | |
v2 = Vertex(Vec3(0, 1, 0), Vec3(0, 1, 0), Vec2(1, 0), Vec3(0,1,0)) | |
v3 = Vertex(Vec3(0, 0, 0), Vec3(0, 1, 0), Vec2(0, 0), Vec3(0,0,1)) | |
tri = Triangle(v1, v2, v3) | |
result = [tri] | |
# --- Create new geom based on the computed triangles now --- | |
# Create geom instance | |
geomFormat = GeomVertexFormat.getV3n3c4t2() | |
geomData = GeomVertexData("vertices", geomFormat, Geom.UHStatic) | |
# Create a new GeomTriangles | |
triangles = GeomTriangles(Geom.UHStatic) | |
# Get the writers | |
posWriter = GeomVertexWriter(geomData, "vertices") | |
normWriter = GeomVertexWriter(geomData, "normal") | |
colorWriter = GeomVertexWriter(geomData, "color") | |
texcWriter = GeomVertexWriter(geomData, "texcoord") | |
geomData.setNumRows(3) | |
# Todo: call set num rows | |
currentIndex = 0 | |
for triangle in result: | |
for vertex in [triangle.a, triangle.b, triangle.c]: | |
posWriter.addData3f(vertex.pos) | |
texcWriter.addData2f(vertex.texc) | |
normWriter.addData3f(vertex.nrm) | |
colorWriter.addData4f(vertex.col) | |
triangles.addVertices(currentIndex, currentIndex+1, currentIndex+2) | |
currentIndex += 3 | |
newGeom = Geom(geomData) | |
newGeom.addPrimitive(triangles) | |
return newGeom |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment