Gehts vielleicht noch kürzer und sinnloser?sechsrad hat geschrieben:anständiger Konverter ins Ogre format
gibt es doch....

MFG PMV
Code: Alles auswählen
;#############################################################
;## ##
;## ConvertMeshData2File() ##
;## ##
;## Author: Morty ##
;## Created: 24.03.2009 ##
;## OS: Windows ##
;## PureBasic: 4.30 ##
;## ##
;## Basiert auf den Daten, die von mpzs (Michael Paulwitz) ##
;## DirectXtoMesh Konverter erzeugt werden. ##
;## ##
;## Schreibt diese Daten in eine beliebige Datei. Das ##
;## vereinfacht das spätere Laden ;o) ##
;## ##
;## So geht's: ##
;## 1. Die erzeugte Datasection am Ende dieses Programms ##
;## einfügen ##
;## 2. Dieses Programm ausführen ##
;## 3. Meshfile speichern -> fertig ##
;#############################################################
#File_Output = 0
#DataInRow = 9
Procedure ConvertMeshData2File(MeshFile_Output.s="")
;Keine Angaben -> FileRequester
If Trim(MeshFile_Output.s)=""
MeshFile_Output.s=SaveFileRequester("Mesh speichern","","MeshFormat (*.pbmesh)|*.pbmesh",0)
EndIf
;Immer noch nix?
If Trim(MeshFile_Output.s)="":ProcedureReturn #False:EndIf
;Endung vorhanden?
If Right(LCase(MeshFile_Output.s),7)<>".pbmesh"
MeshFile_Output.s+".pbmesh"
EndIf
Restore NumericalData
Read.l Vert
Read.l Tria
Read.l Max
Restore StringSect
Read.s Texturname.s
;Vertisen ermitteln
;Datei zum Schreiben öffnen
If CreateFile(#File_Output,MeshFile_Output.s)
;Texturnamen
WriteStringN(#File_Output,Texturname.s)
;Numerical Datas schreiben
WriteLong(#File_Output,Vert)
WriteLong(#File_Output,Tria)
WriteLong(#File_Output,Max)
;Nun die Vertisen schreiben
Restore Vertice
For v=1 To Vert
For c=1 To #DataInRow
Read.f VertData.f
WriteFloat(#File_Output,VertData.f)
Next
Next
;Triangles schreiben
Restore Triangle
For t=1 To Tria
For c=1 To 3
Read.w TriaData.w
WriteWord(#File_Output,TriaData.w)
Next
Next
CloseFile(#File_Output)
ProcedureReturn #True
Else
MessageRequester("Fehler","Ausgabedatei konnte nicht erstellt werden.")
ProcedureReturn #False
EndIf ;if createfile()
EndProcedure
;-BEISPIEL
ConvertMeshData2File()
;-DATASECTION EINFÜGEN
DataSection
;Hier die Daten einfügen
EndDataSection
;<- ENDE DATASECTION
Code: Alles auswählen
;#############################################################
;## ##
;## Load_MeshFile() ##
;## ##
;## Author: Morty ##
;## Created: 24.03.2009 ##
;## OS: Windows ##
;## PureBasic: 4.30 ##
;## ##
;## Basiert auf den Daten, die von mpzs (Michael Paulwitz) ##
;## DirectXtoMesh Konverter erzeugt werden. ##
;## ##
;## Läd' die von ConvertMeshData2File() gespeicherten ##
;## Daten und erstellt den Mesh ##
;## ##
;#############################################################
#File_Input = 1
#DataInRow = 9 ;9 Werte in einer Datenzeile
Structure __MyMeshFormat__
MeshFile.s
MeshID.l
EntityID.l
MaterialID.l
TextureID.l
Vert.l
Tria.l
Max.l
TextureFile.s
EndStructure
Procedure Load_MeshFile(*LoadMesh.__MyMeshFormat__)
If ReadFile(#File_Input,*LoadMesh\MeshFile)
;Textur
*LoadMesh\TextureFile=ReadString(#File_Input)
;Daten
*LoadMesh\Vert=ReadLong(#File_Input)
*LoadMesh\Tria=ReadLong(#File_Input)
*LoadMesh\Max=ReadLong(#File_Input)
;Speicher für die Vertisen
*VertMem=AllocateMemory(*LoadMesh\Vert*#DataInRow*4) ;Anzahl der Vertisen*9 pro Zeile*4 pro Float
FloatOffset.l=0
;Verticen einlesen
For v=1 To *LoadMesh\Vert
For c=1 To #DataInRow
VertData.f=ReadFloat(#File_Input)
PokeF(*VertMem+FloatOffset.l,VertData.f)
FloatOffset.l+4
Next
Next
;Speicher für die Triangles
*TriaMem=AllocateMemory(*LoadMesh\Tria*3*2) ;Anzahl der Triangles * 3 pro Zeile * 2 pro Word
WordOffset.l=0
For t=1 To *LoadMesh\Tria
For c=1 To 3
TriaData.w=ReadWord(#File_Input)
PokeW(*TriaMem+WordOffset.l,TriaData.w)
WordOffset.l+2
Next
Next
CloseFile(#File_Input)
;Mesh erstellen
*LoadMesh\MeshID=CreateMesh(#PB_Any, *LoadMesh\Vert)
SetMeshData(*LoadMesh\MeshID, #PB_Mesh_Vertex | #PB_Mesh_Normal | #PB_Mesh_Color | #PB_Mesh_UVCoordinate, *VertMem, *LoadMesh\Vert);3)
SetMeshData(*LoadMesh\MeshID, #PB_Mesh_Face, *TriaMem, *LoadMesh\Tria); 1)
Add3DArchive(".", #PB_3DArchive_FileSystem) ; Textur in Ordner / Add folder
If FileSize(*LoadMesh\TextureFile) <> -1
*LoadMesh\TextureID=LoadTexture(#PB_Any, *LoadMesh\TextureFile)
*LoadMesh\MaterialID=CreateMaterial(#PB_Any,TextureID(*LoadMesh\TextureID))
*LoadMesh\EntityID=CreateEntity(#PB_Any, MeshID(*LoadMesh\MeshID), MaterialID(*LoadMesh\MaterialID))
Else
*LoadMesh\EntityID=CreateEntity(#PB_Any, MeshID(*LoadMesh\MeshID),#PB_Material_None)
EndIf
;Speicher frei machen
FreeMemory(*VertMem)
FreeMemory(*TriaMem)
Else
MessageRequester("Fehler","Datei konnte nicht geöffnet werden.")
EndIf
EndProcedure
;-BEISPIEL
If InitEngine3D() And InitSprite() And InitKeyboard()
OpenWindow(0,0,0,640,480,"3D Mesh TEST - Key A and Y/Z bewegt/move Mesh",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0),0,0,640,480,0,0,0)
TestMesh.__MyMeshFormat__
TestMesh\MeshFile="TestMesh.pbmesh"
Load_MeshFile(@TestMesh)
CreateLight(0, RGB(255,255,255), 100.0, 0, 0) ; White Light
CreateCamera(0, 0, 0, 100, 100)
z+(TestMesh\Max*2)
CameraLocate(0,0,0,z)
Repeat
ExamineKeyboard()
Select WindowEvent()
Case #PB_Event_CloseWindow
Quit = #True
EndSelect
If KeyboardPushed(#PB_Key_A) ; Key A = Zoom +
z-1
CameraLocate(0,0,0,z)
EndIf
If KeyboardPushed(#PB_Key_Z) ; Key Z = Zoom +
z+1
CameraLocate(0,0,0,z)
EndIf
If KeyboardPushed(#PB_Key_Y) ; Key Y = Zoom +
z+1
CameraLocate(0,0,0,z)
EndIf
;RotateEntity(#Mesh, 1, 1, 1, #PB_Relative)
ClearScreen(RGB(0,0,0))
RenderWorld()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or Quit
Else
MessageRequester("Error", "Cant init DirectX 3D Engine",0)
EndIf
End
Na dann mal her damit. Will es mir gerne mal angucken.mpz hat geschrieben:Hi Morty,
Dein Idee ist nicht schlecht, hier halte ich es aber für sinnvoller gleich ein "Mesh" export zu erstellen um damit dann das Mesh mit den "normalen" Befehlen enlesen zu können. Ist sicherlich für andere PBler super interessant und würde ich auch gerne in das Programm intergrieren. Falls Du dazu Lust hast kann ich Dir das Format der Struktur raussuchen und dir zukommen lassen. Ist sicherlich genauso einfach wie Dein geschriebenes Programm.
Gruß Michael
Code: Alles auswählen
<mesh>
<sharedgeometry vertexcount="24">
<vertexbuffer positions="true" normals="true" colours_diffuse="false" colours_specular="false" texture_coords="1" texture_coord_dimensions_0="2">
<vertex>
<position x="-0.5" y="0.5" z="0.5" />
<normal x="0" y="0" z="1" />
<texcoord u="0" v="-1" />
</vertex>
<vertex>
<position x="-0.5" y="-0.5" z="0.5" />
<normal x="0" y="0" z="1" />
<texcoord u="0" v="-0" />
</vertex>
<vertex>
<position x="0.5" y="-0.5" z="0.5" />
<normal x="0" y="0" z="1" />
<texcoord u="1" v="-0" />
</vertex>
<vertex>
<position x="0.5" y="0.5" z="0.5" />
<normal x="0" y="0" z="1" />
<texcoord u="1" v="-1" />
</vertex>
<vertex>
<position x="0.5" y="0.5" z="-0.5" />
<normal x="0" y="0" z="-1" />
<texcoord u="0" v="-1" />
</vertex>
<vertex>
<position x="0.5" y="-0.5" z="-0.5" />
<normal x="0" y="0" z="-1" />
<texcoord u="0" v="-0" />
</vertex>
<vertex>
<position x="-0.5" y="-0.5" z="-0.5" />
<normal x="0" y="0" z="-1" />
<texcoord u="1" v="-0" />
</vertex>
<vertex>
<position x="-0.5" y="0.5" z="-0.5" />
<normal x="0" y="0" z="-1" />
<texcoord u="1" v="-1" />
</vertex>
<vertex>
<position x="-0.5" y="0.5" z="-0.5" />
<normal x="-1" y="0" z="-0" />
<texcoord u="0" v="-1" />
</vertex>
<vertex>
<position x="-0.5" y="-0.5" z="-0.5" />
<normal x="-1" y="0" z="-0" />
<texcoord u="0" v="-0" />
</vertex>
<vertex>
<position x="-0.5" y="-0.5" z="0.5" />
<normal x="-1" y="0" z="-0" />
<texcoord u="1" v="-0" />
</vertex>
<vertex>
<position x="-0.5" y="0.5" z="0.5" />
<normal x="-1" y="0" z="-0" />
<texcoord u="1" v="-1" />
</vertex>
<vertex>
<position x="0.5" y="-0.5" z="-0.5" />
<normal x="1" y="0" z="-0" />
<texcoord u="1" v="-0" />
</vertex>
<vertex>
<position x="0.5" y="0.5" z="0.5" />
<normal x="1" y="0" z="-0" />
<texcoord u="0" v="-1" />
</vertex>
<vertex>
<position x="0.5" y="-0.5" z="0.5" />
<normal x="1" y="0" z="-0" />
<texcoord u="0" v="-0" />
</vertex>
<vertex>
<position x="0.5" y="0.5" z="-0.5" />
<normal x="1" y="-0" z="-0" />
<texcoord u="1" v="-1" />
</vertex>
<vertex>
<position x="-0.5" y="0.5" z="-0.5" />
<normal x="0" y="1" z="-0" />
<texcoord u="0" v="-1" />
</vertex>
<vertex>
<position x="-0.5" y="0.5" z="0.5" />
<normal x="0" y="1" z="-0" />
<texcoord u="0" v="-0" />
</vertex>
<vertex>
<position x="0.5" y="0.5" z="0.5" />
<normal x="0" y="1" z="-0" />
<texcoord u="1" v="-0" />
</vertex>
<vertex>
<position x="0.5" y="0.5" z="-0.5" />
<normal x="0" y="1" z="0" />
<texcoord u="1" v="-1" />
</vertex>
<vertex>
<position x="0.5" y="-0.5" z="-0.5" />
<normal x="0" y="-1" z="-0" />
<texcoord u="0" v="-1" />
</vertex>
<vertex>
<position x="0.5" y="-0.5" z="0.5" />
<normal x="0" y="-1" z="-0" />
<texcoord u="0" v="-0" />
</vertex>
<vertex>
<position x="-0.5" y="-0.5" z="0.5" />
<normal x="0" y="-1" z="-0" />
<texcoord u="1" v="-0" />
</vertex>
<vertex>
<position x="-0.5" y="-0.5" z="-0.5" />
<normal x="0" y="-1" z="-0" />
<texcoord u="1" v="-1" />
</vertex>
</vertexbuffer>
</sharedgeometry>
<submeshes>
<submesh material="cube" usesharedvertices="true" use32bitindexes="false" operationtype="triangle_list">
<faces count="12">
<face v1="0" v2="1" v3="2" />
<face v1="3" v2="0" v3="2" />
<face v1="4" v2="5" v3="6" />
<face v1="7" v2="4" v3="6" />
<face v1="8" v2="9" v3="10" />
<face v1="11" v2="8" v3="10" />
<face v1="12" v2="13" v3="14" />
<face v1="15" v2="13" v3="12" />
<face v1="16" v2="17" v3="18" />
<face v1="19" v2="16" v3="18" />
<face v1="20" v2="21" v3="22" />
<face v1="23" v2="20" v3="22" />
</faces>
</submesh>
</submeshes>
</mesh>