Hello masters,
After two weeks of studying I tried my first editing at LWO loader. I added these lines right after "case: VMAD". I expected to do nothing with them, but it crashed. Why?
case charsToUIntD('V','M','A','D'): // dicontinuous vertex mapping, i.e. additional texcoords
{
#ifdef LWO_READER_DEBUG
os::Printer::log("LWO loader: loading discontinuous maps VMADS.");
#endif
u32 size;
File->read(&size, 4);
case charsToUIntD('T','X','U','V'): // dicontinuous vertex mapping, i.e. additional texcoords
u16 dimm;
size=(size-4)/12; // how many Txuv vmads are in
u16 points[size];
u16 polys[size];
f32 ucoord[size];
f32 vcoord[size];
u16 counter=0;
for (counter=0; counter<=size; counter++) {
File->read(&points[counter], 2);
File->read(&polys[counter], 2);
File->read(&ucoord[counter], 4);
File->read(&vcoord[counter], 4);
}
}
I'm expected only to read the VMAD chunk and store it.
Added those lines to CLWOMeshFileloader.cpp [SOLVED]
-
- Posts: 260
- Joined: Thu Apr 17, 2008 1:38 pm
- Location: Brasopolis - Brazil
Added those lines to CLWOMeshFileloader.cpp [SOLVED]
Last edited by Auradrummer on Wed Apr 30, 2008 7:03 pm, edited 1 time in total.
Professional Software Developer and Amateur Game Designer
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
No, you are messing with the case statements (now for txuv the program would jump into the middle of the outer block) and you will completely wreck the current file position etc. Remember that the program will continue to parse the file at whatever position you'll leave it after the case statement block has finishes (which should be done with a break statement in order to jump to the end of the switch).
-
- Posts: 260
- Joined: Thu Apr 17, 2008 1:38 pm
- Location: Brasopolis - Brazil
Master Hybrid,
case charsToUIntD('V','M','A','D'): // dicontinuous vertex mapping, i.e. additional texcoords
{
u32 vmsize;
File->read(&vmsize, 4);
f32 jumptype;
File->read(&jumptype,4);
u16 dimm;
File->read(&dimm,2);
core::stringc vmname;
File->read(&vmname,8);
vmsize=(vmsize-18)/12; // how many Txuv vmads are in
u16 points[vmsize];
u16 polys[vmsize];
f32 ucoord[vmsize];
f32 vcoord[vmsize];
u16 counter=0;
for (counter=0; counter<=vmsize; counter++) {
File->read(&points[counter], 2);
File->read(&polys[counter], 2);
File->read(&ucoord[counter], 4);
File->read(&vcoord[counter], 4);
}
}
break;
I think understood what you said. My 'insertion' is making the read sequence get lost.
I think now it should not loose the sequence, but is still loosing. Follow my reasoning:
When the file is being read, the first line (case) 'catches' the read at this point and start reading my code.
Now, I must declare a variable with the type and size matching the information inside the file after the VMAD tag and read it (I'm reading all variables just in the line below declaration), to make the pointer pass. So, follows.
u32 vmsize; // the size of the chunk (4 bytes)
f32 jumptype; // the type of VMAD, that is TXUV (4 bytes). I'm only passing over
u16 dimm; // dimension (is always 0 2 for TXUV's) (2 bytes).
core::stringc vmname; // name. In my file is 7 bytes plus the /0. So i read 8 bytes (only to test):
vmsize=(vmsize-18)/12; // the size of chunk minus what I've read. (I tried with 14, no difference)
u16 points[vmsize]; // point index array, with the number of elements above (2 bytes)
u16 polys[vmsize]; // poly index array, same above (2 bytes)
f32 ucoord[vmsize]; // U coordinate array (4 bytes, float)
f32 vcoord[vmsize]; // V coordinate array (4 bytes, float)
u16 counter=0; // only to make the loop.
for (counter=0; counter<=vmsize; counter++) {
File->read(&points[counter], 2);
File->read(&polys[counter], 2);
File->read(&ucoord[counter], 4);
File->read(&vcoord[counter], 4);
}
}
break;
And the loop should place all the informations in the array aligned, PP.OO.UUUU.VVVVV.
I placed the break, and code passes over if VMAD isn't found (I tested and worked).
Man, I'm searching, searching and no success. Sorry if my mistake is idiot!
Thanks for the help!
case charsToUIntD('V','M','A','D'): // dicontinuous vertex mapping, i.e. additional texcoords
{
u32 vmsize;
File->read(&vmsize, 4);
f32 jumptype;
File->read(&jumptype,4);
u16 dimm;
File->read(&dimm,2);
core::stringc vmname;
File->read(&vmname,8);
vmsize=(vmsize-18)/12; // how many Txuv vmads are in
u16 points[vmsize];
u16 polys[vmsize];
f32 ucoord[vmsize];
f32 vcoord[vmsize];
u16 counter=0;
for (counter=0; counter<=vmsize; counter++) {
File->read(&points[counter], 2);
File->read(&polys[counter], 2);
File->read(&ucoord[counter], 4);
File->read(&vcoord[counter], 4);
}
}
break;
I think understood what you said. My 'insertion' is making the read sequence get lost.
I think now it should not loose the sequence, but is still loosing. Follow my reasoning:
When the file is being read, the first line (case) 'catches' the read at this point and start reading my code.
Now, I must declare a variable with the type and size matching the information inside the file after the VMAD tag and read it (I'm reading all variables just in the line below declaration), to make the pointer pass. So, follows.
u32 vmsize; // the size of the chunk (4 bytes)
f32 jumptype; // the type of VMAD, that is TXUV (4 bytes). I'm only passing over
u16 dimm; // dimension (is always 0 2 for TXUV's) (2 bytes).
core::stringc vmname; // name. In my file is 7 bytes plus the /0. So i read 8 bytes (only to test):
vmsize=(vmsize-18)/12; // the size of chunk minus what I've read. (I tried with 14, no difference)
u16 points[vmsize]; // point index array, with the number of elements above (2 bytes)
u16 polys[vmsize]; // poly index array, same above (2 bytes)
f32 ucoord[vmsize]; // U coordinate array (4 bytes, float)
f32 vcoord[vmsize]; // V coordinate array (4 bytes, float)
u16 counter=0; // only to make the loop.
for (counter=0; counter<=vmsize; counter++) {
File->read(&points[counter], 2);
File->read(&polys[counter], 2);
File->read(&ucoord[counter], 4);
File->read(&vcoord[counter], 4);
}
}
break;
And the loop should place all the informations in the array aligned, PP.OO.UUUU.VVVVV.
I placed the break, and code passes over if VMAD isn't found (I tested and worked).
Man, I'm searching, searching and no success. Sorry if my mistake is idiot!
Thanks for the help!
Professional Software Developer and Amateur Game Designer
-
- Posts: 260
- Joined: Thu Apr 17, 2008 1:38 pm
- Location: Brasopolis - Brazil
I took a look of the start of switch, and there the 'size' is the size of whole file, right? This line is before the 'cases'.
File->read(&size, 4);
after this I didn't found where the size reads the size of the chunk. I found that some chunks are subtracted of size after read.
Another thing, how can I turn on the debug mode? I'm using the hello.world to test LWO loading, and I'm not receiving any message.
Sorry for take your time, but I promiss that you won't arrepent.
File->read(&size, 4);
after this I didn't found where the size reads the size of the chunk. I found that some chunks are subtracted of size after read.
Another thing, how can I turn on the debug mode? I'm using the hello.world to test LWO loading, and I'm not receiving any message.
Sorry for take your time, but I promiss that you won't arrepent.
Professional Software Developer and Amateur Game Designer
-
- Posts: 260
- Joined: Thu Apr 17, 2008 1:38 pm
- Location: Brasopolis - Brazil
MAAAASTEEEEER!!!!!!
I DID IT!!!!! Here is all the coordinates of the discontinuous UV map of my little boxy!!!!!!!! I'M EUPHORIC!!!!!!!! WORKEEEEEED!!!!!!!
To read it properly I had to use 'byteswap' in all the data. This is an characteristic of Irrlicht engine, C or LWO? Only to know...
I DID IT!!!!! Here is all the coordinates of the discontinuous UV map of my little boxy!!!!!!!! I'M EUPHORIC!!!!!!!! WORKEEEEEED!!!!!!!
To read it properly I had to use 'byteswap' in all the data. This is an characteristic of Irrlicht engine, C or LWO? Only to know...
Professional Software Developer and Amateur Game Designer
-
- Posts: 1638
- Joined: Mon Apr 30, 2007 3:24 am
- Location: Montreal, CANADA
- Contact:
-
- Posts: 260
- Joined: Thu Apr 17, 2008 1:38 pm
- Location: Brasopolis - Brazil
Hey Clavet,
Sorry, I didn't see your reply. The mail notification isn't working for me. I made the code reading, but not applying. I used a non-standard way to read, and I had some problem now I have to mix the code Irrlicht already have with my code. So, I'm reworking it with some alterations, to be more friendly with Irrlicht.
Sorry, I didn't see your reply. The mail notification isn't working for me. I made the code reading, but not applying. I used a non-standard way to read, and I had some problem now I have to mix the code Irrlicht already have with my code. So, I'm reworking it with some alterations, to be more friendly with Irrlicht.
Professional Software Developer and Amateur Game Designer