Meshs laden, zusammenfügen, speichern - geht nicht!

Übersicht BlitzBasic Blitz3D

Neue Antwort erstellen

 

BadDeath

Betreff: Meshs laden, zusammenfügen, speichern - geht nicht!

BeitragDo, Jul 17, 2008 1:01
Antworten mit Zitat
Benutzer-Profile anzeigen
Ich bin's mal wieder mit einem neuen Problem.... Embarassed

Ich möchte gerne 5 Meshs laden, diese zusammenfügen und wieder speichern. Der Code macht das auch theoretisch und die neue Datei ist auch so groß wie die 5 anderen zusammen. Doch zeigt mir der DirectX Viewer (geladene und gespeicherte Dateien sind *.x) nur den Teil vom ersten Mesh an.

So ist der Code (die Speicherfunktion stammt aus dem englischen Board):

Code: [AUSKLAPPEN]
Graphics3D 250,20,32,2

Local Projekt$ = Input("Projekt: ")
Cls

Graphics3D 250,1,32,2

Local Dir=ReadDir(Projekt)
Repeat
   Local file$=NextFile$(Dir)
   If file$="" Then Exit
   If FileType(Projekt+"\"+file$) = 1 And Left(file$,Len(Projekt)) = Projekt Then Counter=Counter+1
Forever
CloseDir Dir

Dim Mesh(Counter)
EndMesh = CreateMesh()

For i = 1 To Counter
   AppTitle "Lade " + i + "/" + Counter
   Mesh(i) = LoadMesh(projekt+" "+i+".x")
   AddMesh (Mesh(i), EndMesh)
   FreeEntity Mesh(i)
Next

AppTitle "Speichere"
SaveMeshX(EndMesh, Projekt+"\FINISH.x")
End





Function SaveMeshX(mesh,file$)
;single surface at the moment
    cnt=CountSurfaces(mesh)
    If cnt=0 Then Return
   
    ;TODO Multi surface support
    surf=GetSurface(mesh,1)
   
    out=WriteFile(file$)
    WriteLine out,"xof 0302txt 0064"
    WriteLine out,""
    WriteLine out,"Header {"
    WriteLine out," 1;"
    WriteLine out," 0;"
    WriteLine out," 1;"
    WriteLine out,"}"
    WriteLine out,""
    WriteLine out,"Frame frm_Scene_Root {"
    WriteLine out," FrameTransformMatrix {"
    WriteLine out," 1.000000,0.000000,0.000000,0.000000,"
    WriteLine out," 0.000000,1.000000,0.000000,0.000000,"
    WriteLine out," 0.000000,0.000000,1.000000,0.000000,"
    WriteLine out," 0.000000,0.000000,0.000000,1.000000;"
    WriteLine out,"}"
    WriteLine out,""   
    name$=EntityName$(mesh)
    If name$="" Then name$="3D-Scan"
    WriteLine out,"Frame frm_"+name$+" {"
    WriteLine out," FrameTransformMatrix {"
    WriteLine out," 1.000000,0.000000,0.000000,0.000000,"
    WriteLine out," 0.000000,1.000000,0.000000,0.000000,"
    WriteLine out," 0.000000,0.000000,1.000000,0.000000,"
    WriteLine out," 0.000000,0.000000,0.000000,1.000000;"
    WriteLine out,"}"
    WriteLine out,""
    WriteLine out," Mesh frm_"+name$+" {"
    WriteLine out,CountVertices(surf)+";"
    For a=0 To CountVertices(surf)-1
        WriteLine out,VertexX(surf,a)+";"+VertexY(surf,a)+";"+VertexZ(surf,a)+";,"
    Next
    WriteLine out,""
    WriteLine out," "+CountTriangles(surf)+";"
    For a=0 To CountTriangles(surf)-1
        in1=TriangleVertex(surf,a,0)
        in2=TriangleVertex(surf,a,1)
        in3=TriangleVertex(surf,a,2)
        ln$=" 3;"+in1+","+in2+","+in3+";"
        If a=CountTriangles(surf)-1 Then ln$=ln$+";" Else ln$=ln$+","
        WriteLine out,ln$
    Next
    WriteLine out,""

    WriteLine out,"MeshMaterialList {"
    WriteLine out,"1;"
    WriteLine out,"1;"
    WriteLine out,"0;;"
    WriteLine out,""
    WriteLine out,"Material {"

    WriteLine out," 1.000000,1.000000,1.000000,1.000000;;";rgba
    WriteLine out," 1.000000;"
    WriteLine out," 0.500000,0.500000,0.500000;;"
    WriteLine out," 0.000000,0.000000,0.000000;;"
    WriteLine out,"}"
    WriteLine out,"}"
    WriteLine out,""
    WriteLine out,"MeshNormals {"
    WriteLine out,CountVertices(surf)+";"
    For a=0 To CountVertices(surf)-1
        WriteLine out,VertexNX(surf,a)+";"+VertexNY(surf,a)+";"+VertexNZ(surf,a)+";,"
    Next
    WriteLine out," "+CountTriangles(surf)+";"
    For a=0 To CountTriangles(surf)-1
        in1=TriangleVertex(surf,a,0)
        in2=TriangleVertex(surf,a,1)
        in3=TriangleVertex(surf,a,2)
        ln$=" 3;"+in1+","+in2+","+in3+";"
        If a=CountTriangles(surf)-1 Then ln$=ln$+";" Else ln$=ln$+","
        WriteLine out,ln$
    Next
    WriteLine out,"}"
    WriteLine out,""

    WriteLine out,"MeshTextureCoords {"
    WriteLine out,CountVertices(surf)+";"
    For a=0 To CountVertices(surf)-1
        ln$=VertexU(surf,a)+";"+VertexV(surf,a)+";"
        If a=CountVertices(surf)-1 Then ln$=ln$+";" Else ln$=ln$+","
        WriteLine out,ln$
    Next
    WriteLine out," }"
    WriteLine out," }"
    WriteLine out," }"
    WriteLine out,"}"
    CloseFile out
End Function


Und in Blitz kann ich mir das ganze nicht angugcken, da es zu viele Polygone hat - liegt es dadran? Jeder Teil besteht aus bis zu 1600 Würfeln = 19200 Tris.

Hier mal die Beispieldatein (auf Rapidshare, da die für das Board zu groß sind und Kilu gerade Log-in-Probleme hat).
-~= real coders just code in binary =~-

Eingeproggt

BeitragDo, Jul 17, 2008 1:48
Antworten mit Zitat
Benutzer-Profile anzeigen
Liegt möglicherweise an der Triangle-Anzahl.
Siehe Diskussion in diesem Thread:
https://www.blitzforum.de/foru...++triangle

mfG, Christoph.
Gewinner des BCC 18, 33 und 65 sowie MiniBCC 9
 

BadDeath

BeitragDo, Jul 17, 2008 13:40
Antworten mit Zitat
Benutzer-Profile anzeigen
Dann habe ich wohl eindeutig zuviele Polygone - die finale Datei ist 12,1 MB groß Rolling Eyes

Irgendwie muss ich eine "Hülle" drum bauen, dann sieht es auch gleich besser aus, als würde alles aus Würfeln bestehen. Nur habe ich leider keine genaue Idee wie, außer, dass man ein Mesh erstellt und dann z.B. die Koordinaten jedes zweiten Würfels für die Eckdaten eines Triangles nimmt...

Hat jemand eine Idee, wie man das realisieren könnte?
-~= real coders just code in binary =~-

Neue Antwort erstellen


Übersicht BlitzBasic Blitz3D

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group