#129406 - a128 - Tue May 22, 2007 3:38 pm
Hi!
I write a displaylist converter for 3ds files....the displaylists shows up
on no$gba 2.4a emulator and Ideas 1.0.5
it does not show up on DS hardware
I have no clue why ?
I use VERTEX16 and also scale the model down to -8....+8 if some verts are >+-8
I also optional use VERTEX10 which I convert like this:
#define floattovtx10(n) ((short)((n) * (1 << 6))) /*!< \brief convert float to vtx10 */
short x=floattovtx10(m->vlist[index[tri]].x/scale_);
short y=floattovtx10(m->vlist[index[tri]].y/scale_);
short z=floattovtx10(m->vlist[index[tri]].z/scale_);
u32 xyz= NORMAL_PACK(x,y,z);
Last edited by a128 on Thu May 24, 2007 1:19 pm; edited 1 time in total
#129524 - a128 - Wed May 23, 2007 2:11 pm
Searching for the error....it seems that the Normals are wrong....leaving the normal out the hardware displays the 3d object
I guess floattov10 () is still broken
I uses the latest NDS lib with
Code: |
#define floattov10(n) ((n>.998) ? 0x1FF : ((v10)((n)*(1<<9)))) /*!< \brief convert float to v10 */
#define NORMAL_PACK(x,y,z) (((x) & 0x3FF) | (((y) & 0x3FF) << 10) | ((z) << 20)) /*!< \brief Pack 3 v10 normals i |
Last edited by a128 on Wed May 23, 2007 3:28 pm; edited 1 time in total
#129527 - a128 - Wed May 23, 2007 3:31 pm
I use libnds and no$gba ...all legal
but thanks for your advice in general
Last edited by a128 on Thu May 24, 2007 1:18 pm; edited 1 time in total
#129534 - silent_code - Wed May 23, 2007 4:15 pm
you better do. and as a personal advise: watch what you're posting. if i was a mod, i'd given you a warning.
happy coding, though! ;^p
#129762 - gabebear - Sat May 26, 2007 5:32 am
Hmm, I don't know why that is happening. Normally a normal problem would just cause the lighting to be a little wrong, not make the model not load. If the model isn't loading at all then I'm betting the normals aren't really the problem.
Are all your models failing to load when you run them through that way? If it doesn't always happen then I may have some ideas. Try not sending glEnd commands, they are never needed and calling glEnd in a display list can make the DS lock up.
I made a very rough .PLY to display list converter at http://www.ghearing.com/mtutorial/ . I don't know if looking at the source for that one would help or hurt you... I should go back and clean it up... well rewrite it.
#129934 - a128 - Tue May 29, 2007 8:44 am
What's strange is that it works on No$gba emulator and Ideas BUT not on hardware
when I not use the Normals ...the displaylist displays on hardware
even with FIFO_END
btw. I use packed command
#129971 - gabebear - Tue May 29, 2007 4:55 pm
a128, I have several questions
1. Did you try NOT using FIFO_END?
2. How many models have you tried in your display list converter?
3. Do all the models screw up, or just a handful?
4. Have you gotten the picking example working?(other thread)
None of the emulators are good at emulating the 3D hardware, so you need to test on actual hardware very often. I almost never use an emulator.
#130023 - a128 - Wed May 30, 2007 8:28 am
Quote: |
1. Did you try NOT using FIFO_END?
2. How many models have you tried in your display list converter?
3. Do all the models screw up, or just a handful?
4. Have you gotten the picking example working?(other thread)
|
First of all.....I dicovered a bug during my normal setup.....now the normals are correct....no$gba displays the lighting now correct...but the hardware displays nothing (:-
1. Yes...with FIFIO_END or not ....nothing happend on hardware..
2. 1 model
3. all models
4. I not tried it...but I will test that one again
If I just leave the normals out of the displaylist the model is shown on hardware
#130054 - a128 - Wed May 30, 2007 3:28 pm
gabebear:
I found your PLY Displaylist convert very usefull.
I like to scale any Model to -1,-1,-1 ...+1,+1,+1
This way you can via glScale(size) resize your model and your code knows about the model size
so in your void scale() method do
Code: |
//compute maxX,.......minZ
......
float BASE=1;//+8
// Set vertices to [(-BASE,-BASE,-BASE);(BASE,BASE,BASE)]
float tlx = (maxX + minX) / 2.0f;
float tly = (maxY + minY) / 2.0f;
float tlz = (maxZ + minZ) / 2.0f;
float scalex = (maxX - minX) * 0.5f;
float scaley = (maxY - minY) * 0.5f;
float scalez = (maxZ - minZ) * 0.5f;
float sc=MAX(MAX(scalex,scaley),scalez)/BASE;
printf("Info: Box extensions Min:X %f,Y %f,Z %f Max:X %f,Y %f,Z %f\n",minX,minY,minZ,maxX,maxY,maxZ);
printf("Info: Box extensions Height %f, Width %f, Depth %f\n",-minY+maxY,-minX+maxX,-minZ+maxZ);
printf("Info: tlx %f, tly %f, tlz %f\n sc %f\n",tlx,tly,tlz,sc);
// scale the verts
for(int i=0;i<numVerts;i++) {
vertices[i].x-=tlx;
vertices[i].y-=tly;
vertices[i].z-=tlz;
vertices[i].x/=sc;
vertices[i].y/=sc;
vertices[i].z/=sc;
}
}
|
#130308 - gabebear - Sat Jun 02, 2007 2:11 am
Scaling everything to 7.99 <-> -8.00 would make more sense; you get eight times more precision on the model. Using 7.99 <-> -8.00 then most of your models will still look good using 10bit coords, which shrinks the size of the display list considerably.
#130507 - a128 - Mon Jun 04, 2007 8:57 am
gabebear wrote: |
Scaling everything to 7.99 <-> -8.00 would make more sense; you get eight times more precision on the model. Using 7.99 <-> -8.00 then most of your models will still look good using 10bit coords, which shrinks the size of the display list considerably. |
then just use
in the code from my previous posting
rescale with glScale(sc) during rendering..so your model has the the same size before the scaling had taken place