Idee die dahinter gesteckt HATTE war, das man eine Szene mit Blitz erstellt und sie dann 1 zu 1 nochmal in Fotoqualität mit einem Raytracer rendert. Leider fehlen ein haufen Entityattribute so dass das Ganze leider nicht geht. Also hier nur einen kleinen Mesh exporter. Er unterstützt Normals und UV-Koordinaten. Wie man Multitexturkoordinaten in POVRay setzt, weiss ich leider nicht. Hätte noch gerne Texturen hinzugefügt, aber GetBrushTexture liefert mir falsche Werte zurück.
BlitzBasic: [AUSKLAPPEN] [EINKLAPPEN] Graphics3D 640, 480, 32, 2
cube = CreateCube() NameEntity cube, "Cube"
camera = CreateCamera() PositionEntity camera, 0, 0, -4
light = CreateLight() PositionEntity light, 0, 0, -4
SavePOV(cube, "cube.inc") RenderWorld Flip
Function SavePOV(mesh, povFile$) Local stream, surfaceCount, s, surface, vertexCount, v, tmpLine$ Local brush, texture ,triangleCount, t stream = WriteFile(povFile$) If stream = False Then Return False EndIf If EntityName$(mesh) = "" Then WriteLine stream, "declare mMesh = union {" Else WriteLine stream, "declare m"+EntityName$(mesh)+" = union {" EndIf surfaceCount = CountSurfaces(mesh) For s = 1 To surfaceCount surface = GetSurface(mesh, s) vertexCount = CountVertices(surface) triangleCount = CountTriangles(surface) WriteLine stream, " // surface"+s WriteLine stream, " mesh2 {" WriteLine stream, " vertex_vectors {" WriteLine stream, " "+vertexCount For v = 0 To vertexCount-1 tmpLine$ = " <" tmpLine$ = tmpLine$+VertexX#(surface, v)+", " tmpLine$ = tmpLine$+VertexY#(surface, v)+", " If v = vertexCount-1 Then tmpLine$ = tmpLine$+VertexZ#(surface, v)+">" Else tmpLine$ = tmpLine$+VertexZ#(surface, v)+">," EndIf WriteLine stream, tmpLine$ : tmpLine$ = "" Next WriteLine stream, " }" WriteLine stream, " normal_vectors {" WriteLine stream, " "+vertexCount For v = 0 To vertexCount-1 tmpLine$ = " <" tmpLine$ = tmpLine$+VertexNX#(surface, v)+", " tmpLine$ = tmpLine$+VertexNY#(surface, v)+", " If v = vertexCount-1 Then tmpLine$ = tmpLine$+VertexNZ#(surface, v)+">" Else tmpLine$ = tmpLine$+VertexNZ#(surface, v)+">," EndIf WriteLine stream, tmpLine$ : tmpLine$ = "" Next WriteLine stream, " }" WriteLine stream, " uv_vectors {" WriteLine stream, " "+vertexCount For v = 0 To vertexCount-1 tmpLine$ = " <" tmpLine$ = tmpLine$+VertexU#(surface, v)+", " If v = vertexCount-1 Then tmpLine$ = tmpLine$+VertexV#(surface, v)+">" Else tmpLine$ = tmpLine$+VertexV#(surface, v)+">," EndIf WriteLine stream, tmpLine$ : tmpLine$ = "" Next WriteLine stream, " }" WriteLine stream, " face_indices {" WriteLine stream, " "+triangleCount For t = 0 To triangleCount-1 tmpLine$ = " <" tmpLine$ = tmpLine$+TriangleVertex(surface, t, 0)+", " tmpLine$ = tmpLine$+TriangleVertex(surface, t, 1)+", " If t = triangleCount-1 Then tmpLine$ = tmpLine$+TriangleVertex(surface, t, 2)+">" Else tmpLine$ = tmpLine$+TriangleVertex(surface, t, 2)+">," EndIf WriteLine stream, tmpLine$ : tmpLine$ = "" Next WriteLine stream, " }" WriteLine stream, " }" Next WriteLine stream, "" WriteLine stream, " texture {" WriteLine stream, " pigment { rgb<1, 1, 1> }" WriteLine stream, " }" WriteLine stream, "}" CloseFile stream Return True End Function
Und die Beispielszene dazu:
BlitzBasic: [AUSKLAPPEN] [EINKLAPPEN] #Include "cube.inc"
camera { location <0, 0, -4> rotate <0, 0, 0> }
light_source { <0, 0, -4> Color rgb <1, 1, 1> }
mCube
Achja und hier noch ein paar gute Tuts zu POVRay: http://www.f-lohmueller.de/pov_tut/pov__ger.htm
mfg olli
|