Guten Tag.
Ich möchte infomrmationen über ein 3D-Modell aus einer datei laden, binär gespeichert. Der erste einzulesende Wert ist ein Integer.
Mein Problem ist das folgende: der eingelesene Wert ist falsch.
Nach ein wenig Fehlersuche mit dem Debugger hat sich folgendes ergeben:
leider is mir nich bekannt, welche der Variablen wie belegt sein muss. Allerdings glaub ich nicht, dass es richtig ist, dass fd = -1 ist, bzw. dass channel = null ist. Kann mich aber auch jederzeit irren.
zum schluss noch der Code, mit dem ich das Model lade:
Hoffe, ihr könnt mir helfen...
danke im Vorraus
Ich möchte infomrmationen über ein 3D-Modell aus einer datei laden, binär gespeichert. Der erste einzulesende Wert ist ein Integer.
Mein Problem ist das folgende: der eingelesene Wert ist falsch.
Code:
numFaces= -1342111744
numTexCoords= -150994944
numVerts= -671088640
Nach ein wenig Fehlersuche mit dem Debugger hat sich folgendes ergeben:
Code:
- stream= DataInputStream (id=27)
+ bytearr= byte[80] (id=33)
+ chararr= char[80] (id=35)
- in= FileInputStream (id=36)
channel= null
- fd= FileDescriptor (id=41)
fd= -1
handle= 4496
lineBuffer= null
+ readBuffer= byte[8] (id=39)
leider is mir nich bekannt, welche der Variablen wie belegt sein muss. Allerdings glaub ich nicht, dass es richtig ist, dass fd = -1 ist, bzw. dass channel = null ist. Kann mich aber auch jederzeit irren.
zum schluss noch der Code, mit dem ich das Model lade:
Code:
public void Load(String filename) throws IOException {
//File file = new File(filename);
DataInputStream stream;
stream = new DataInputStream(new FileInputStream(new File(filename)));
/*if (!file.canRead())
System.out.println("Datei "+filename+" konnte nicht geöffnet werden!");*/
numVerts = stream.readInt();
numTexCoords = stream.readInt();
numFaces = stream.readInt();
vertexList = new CVector[numVerts];
texCoordList = new CTexCoord[numTexCoords];
faceList = new CFace[numFaces];
for (int i=0; i<numVerts; i++) {
vertexList[i] = new CVector();
vertexList[i].x = stream.readFloat();
vertexList[i].y = stream.readFloat();
vertexList[i].z = stream.readFloat();
}
for (int i=0; i<numVerts; i++) {
normalList[i] = new CVector();
normalList[i].x = stream.readFloat();
normalList[i].y = stream.readFloat();
normalList[i].z = stream.readFloat();
}
for (int i=0; i<numTexCoords; i++) {
texCoordList[i] = new CTexCoord();
texCoordList[i].s = stream.readFloat();
texCoordList[i].t = stream.readFloat();
}
for (int i=0; i<numFaces; i++) {
faceList[i] = new CFace();
faceList[i].vertIndices[0] = stream.readInt();
faceList[i].vertIndices[1] = stream.readInt();
faceList[i].vertIndices[2] = stream.readInt();
faceList[i].texCoordIndices[0] = stream.readInt();
faceList[i].texCoordIndices[1] = stream.readInt();
faceList[i].texCoordIndices[2] = stream.readInt();
}
stream.close();
}
Hoffe, ihr könnt mir helfen...
danke im Vorraus