PDA

View Full Version : Slight hiccup importing a LWO file



Sad Penguin
03-17-2005, 07:37 PM
For some reason when this gets to the PNTS chunk, it returns a HUGE number.

byte_4 is a 4 dimension char array
ChunkToUInt takes a chuck, converts it to the correct endian, and returns a number.

This works fine for TAGS and LAYR, but when it gets to PNTS, the length (here pos) of the chunk is returned as many times greater than even the filesize.

What am I doing wrong? (This is with LW8, just using save then loading a saved file...) :confused:


// if ( CompareChunk( "LWO2", byte_4 ) == false ){return false;}

do {
//get chunk stream
fread( byte_4, 4, 1, mdl );
foundchunk = false;

//loading chunk data will be here

if (foundchunk == false) {
fread( byte_4, 4, 1, mdl );
pos = ChunkToUInt( byte_4 );
for (int add_cnt = 1; add_cnt <= pos; add_cnt++)
fread( &ch, 1, 1, mdl );
if (pos%2 == 1) { fread( &ch, 1, 1, mdl );}
}
} while ( ftell( mdl ) != datasize + 8);

Adrian Lopez
03-23-2005, 09:30 PM
Edit: I misunderstood your code... please ignore my previous reply.

fortress
03-24-2005, 08:49 PM
well i dont have an answer fr you but looking at your code are you wrighting a mdl importer
basiclly a hl2 model importer

hehe nm i understand now

Adrian Lopez
04-07-2005, 06:03 PM
Have you figured out what's wrong? I'm curious to learn what's going on. Could you send me a copy of the problem file? I have a rudimentary (and quite incomplete) loader and I'd like to find out if it can read the file that's giving you problems. So far I've only tested it with files generated by Lightwave 7.5.