die daten "CubeVertices" und "CubeFacesIndexes" habe ich dann von hand eingegeben und es funktioniert. die daten habe ich aus dem exportierten datenpaket, siehe ganz unten.
nun meine frage an die fachleute :
wie kann ich die daten dort auslesen und hier : SetMeshData(0, #PB_Mesh_Vertex , ?CubeVertices , 24) reinsetzen.
ich habe schon eine inprovisierte textdatei angelegt, wo nur diese daten untereinander stehen.
wie kann man dann aus einer normalen textdatei die daten auslesen und davon ein mesh machen. dieses ist meine schwierigkeit
wenn mir mal einer zeigen könnte wie der meshkörper ohne die datazeilen erstellt wird, nur auslesen aus einer textdatei und dann der meshvariablen diese daten mitteilen , also hier die daten rein :
SetMeshData(0, #PB_Mesh_Vertex , ?CubeVertices , 24)
SetMeshData(0, #PB_Mesh_Face , ?CubeFacesIndexes , 12)
das beispielprogramm :
Code: Alles auswählen
If InitEngine3D() And InitSprite()
OpenWindow(0,0,0,640,480,"3D Mesh Test",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0),0,0,640,480,0,0,0)
CreateMesh(0,1000)
SetMeshData(0, #PB_Mesh_Vertex , ?CubeVertices , 24)
SetMeshData(0, #PB_Mesh_Face , ?CubeFacesIndexes , 12)
CreateTexture(0,64,64)
StartDrawing(TextureOutput(0))
Box(0,0,64,64,$00ff00)
StopDrawing()
CreateEntity(0, MeshID(0), CreateMaterial(0, TextureID(0)))
ScaleEntity(0, 0.1, 0.1, 0.1)
CreateCamera(0, 0, 0, 100, 100)
CameraLocate(0,1.5,1.5,10)
Repeat
For a=0 To 360
RotateEntity(0, a, a, a)
RenderWorld()
FlipBuffers()
Next a
Until KeyboardPushed(#PB_Key_Escape) Or Quit
Else
MessageRequester("Error", "Cant init DirectX 3D Engine",0)
EndIf
End
DataSection
CubeVertices:
Data.f -23.5955, -2.35955, -14.382
Data.f 5.16854, -2.35955, -14.382
Data.f 5.16854, 22.809, -14.382
Data.f -23.5955, 22.809, -14.382
Data.f -23.5955, -2.35955, 14.382
Data.f -23.5955, 22.809, 14.382
Data.f 5.16854, 22.809, 14.382
Data.f 5.16854, -2.35955, 14.382
Data.f -23.5955, -2.35955, -14.382
Data.f -23.5955, 22.809, -14.382
Data.f -23.5955, 22.809, 14.382
Data.f -23.5955, -2.35955, 14.382
Data.f 5.16854, -2.35955, -14.382
Data.f 5.16854, -2.35955, 14.382
Data.f 5.16854, 22.809, 14.382
Data.f 5.16854, 22.809, -14.382
Data.f -23.5955, 22.809, -14.382
Data.f 5.16854, 22.809, -14.382
Data.f 5.16854, 22.809, 14.382
Data.f -23.5955, 22.809, 14.382
Data.f -23.5955, -2.35955, -14.382
Data.f -23.5955, -2.35955, 14.382
Data.f 5.16854, -2.35955, 14.382
Data.f 5.16854, -2.35955, -14.382
CubeFacesIndexes:
Data.w 0, 2, 1
Data.w 0, 3, 2
Data.w 4, 6, 5
Data.w 4, 7, 6
Data.w 8, 10, 9
Data.w 8, 11, 10
Data.w 12, 14, 13
Data.w 12, 15, 14
Data.w 16, 18, 17
Data.w 16, 19, 18
Data.w 20, 22, 21
Data.w 20, 23, 22
EndDataSection
hier die datei von anim80r ,wie der würfel exportiert ist :
Code: Alles auswählen
// Export object "object01"
// Created with Anim8or 0.95
#include "Anim8orExport.h"
// cube01
static float cube01_coords[] = {
-23.5955, -2.35955, -14.382,
5.16854, -2.35955, -14.382,
5.16854, 22.809, -14.382,
-23.5955, 22.809, -14.382,
-23.5955, -2.35955, 14.382,
-23.5955, 22.809, 14.382,
5.16854, 22.809, 14.382,
5.16854, -2.35955, 14.382,
-23.5955, -2.35955, -14.382,
-23.5955, 22.809, -14.382,
-23.5955, 22.809, 14.382,
-23.5955, -2.35955, 14.382,
5.16854, -2.35955, -14.382,
5.16854, -2.35955, 14.382,
5.16854, 22.809, 14.382,
5.16854, 22.809, -14.382,
-23.5955, 22.809, -14.382,
5.16854, 22.809, -14.382,
5.16854, 22.809, 14.382,
-23.5955, 22.809, 14.382,
-23.5955, -2.35955, -14.382,
-23.5955, -2.35955, 14.382,
5.16854, -2.35955, 14.382,
5.16854, -2.35955, -14.382,
};
static float cube01_normals[] = {
0, 0, -1,
0, 0, -1,
0, 0, -1,
0, 0, -1,
0, 0, 1,
0, 0, 1,
0, 0, 1,
0, 0, 1,
-1, 0, 0,
-1, 0, 0,
-1, 0, 0,
-1, 0, 0,
1, 0, 0,
1, 0, 0,
1, 0, 0,
1, 0, 0,
0, 1, 0,
0, 1, 0,
0, 1, 0,
0, 1, 0,
0, -1, 0,
0, -1, 0,
0, -1, 0,
0, -1, 0,
};
static float cube01_texcoords[] = {
0, 0,
1, 0,
1, 1,
0, 1,
0, 0,
0, 1,
1, 1,
1, 0,
0, 0,
0, 1,
0, 1,
0, 0,
1, 0,
1, 0,
1, 1,
1, 1,
0, 1,
1, 1,
1, 1,
0, 1,
0, 0,
0, 0,
1, 0,
1, 0,
};
static int cube01_indices[] = {
0, 2, 1,
0, 3, 2,
4, 6, 5,
4, 7, 6,
8, 10, 9,
8, 11, 10,
12, 14, 13,
12, 15, 14,
16, 18, 17,
16, 19, 18,
20, 22, 21,
20, 23, 22,
};
static unsigned char cube01_matindices[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0,
};
static Anim8orMaterial cube01_materials[] = {
{
{ 0.878, 0.878, 0.878, 1, }, // Ambient color
{ 0.878, 0.878, 0.878, 1, }, // Diffuse color
{ 1, 1, 1, 1, }, // Specular color
{ 0, 0, 0, 1, }, // Emissive color
0.3, 0.7, 0.2, 0, 32, 1, // Ka, Kd, Ks, Ke, PhongSize, Brilliance
"", // ambient texture
"", // diffuse texture
"", // specular texture
"", // emissive texture
"", // transparency texture
"", // bumpmap texture
"", // environment texture
},
};
static struct Anim8orMesh cube01 = {
"cube01", 24, 36, cube01_indices, cube01_matindices,
cube01_coords, cube01_normals, cube01_texcoords, cube01_materials,
};
// Object object01
struct Anim8orObject object_object01 = {
"object01", 1, // Num Meshes
{
&cube01,
},
};
// End of file