Hi Kefrens,
Thanks for your reply.
When I use your random normal function, it does show something:
Random normals: http://www.donkerdump.nl/fotos/s_random_normals.png
Lib3ds generated normals(with lib3ds_mesh_calculate_normals):
http://www.donkerdump.nl/fotos/s2_lib3ds_gen_normals.png
Face normals(face->normal):
http://www.donkerdump.nl/fotos/s3_lib3ds_face_normals.png

The first option simply does this:
-- Begin Code --
    m_normals = new GLfloat[m_NumFaces * NORMALS_PER_FACE * 3];
    GenRandomNormals(m_normals, m_NumFaces * NORMALS_PER_FACE);
-- End Code --

The second option does this:
-- Begin Code--
        Lib3dsVector * normals = new Lib3dsVector[mesh->faces *
VERTICES_PER_FACE];
        lib3ds_mesh_calculate_normals(mesh, normals);
        for(unsigned int i = 0; i < mesh->faces; i++)
        {
            Lib3dsFace * face = &mesh->faceL[i];
            for(unsigned int j = 0;j < 3;j++)
            {
                memcpy(&m_normals[(cur_face * NORMALS_PER_FACE + j) * 3],
normals[i*NORMALS_PER_FACE + j], sizeof(Lib3dsVector));
            }
            cur_face++;
        }
-- End Code --

The third method looks a lot like the second one, except that it uses the
normal of the face three times:
-- Begin Code --
        for(unsigned int i = 0; i < mesh->faces; i++)
        {
            Lib3dsFace * face = &mesh->faceL[i];
            for(unsigned int j = 0;j < 3;j++)
            {
                memcpy(&m_normals[(cur_face * NORMALS_PER_FACE + j) * 3],
face->normal, sizeof(Lib3dsVector));
            }
            cur_face++;
        }
-- End Code --

I'm pretty sure the problem is not caused by my model, because my
normal-vectors look normal(I've printed their values from m_normals) and
when I use 3dsplay.c from lib3ds, the model gets rendered correctly.
Some normals:

-- Begin Output --
( -0.415021, -0.505704, -0.756321 )
( -0.415021, -0.505704, -0.756321 )
( -0.415021, -0.505704, -0.756321 )
( 0, 0, 1 )
( 0, 0, 1 )
( 0, 0, 1 )
( 0.773012, 0.634392, -9.3246e-08 )
( 0.773012, 0.634392, -9.3246e-08 )
( 0.773012, 0.634392, -9.3246e-08 )
( 0.773011, 0.634393, 6.88186e-08 )
( 0.773011, 0.634393, 6.88186e-08 )
( 0.773011, 0.634393, 6.88186e-08 )
( 0.881922, 0.471395, -1.23903e-07 )
( 0.881922, 0.471395, -1.23903e-07 )
( 0.881922, 0.471395, -1.23903e-07 )
-- End Output --

Also, the problem is not related to copying the normals, because i've used
assert to check whether the values are equal:
-- Begin Code --
                assert(m_normals[ (cur_face*VERTICES_PER_FACE + j) * 3+0] ==
normals[i*NORMALS_PER_FACE + j][0]);
                assert(m_normals[ (cur_face*VERTICES_PER_FACE + j) * 3+1] ==
normals[i*NORMALS_PER_FACE + j][1]);
                assert(m_normals[ (cur_face*VERTICES_PER_FACE + j) * 3+2] ==
normals[i*NORMALS_PER_FACE + j][2]);
-- End Code --

I hope you (or anyone else on this list) can help me further analyze the
problem, because I know the problem is in my code, but I have no idea what
it could be.
Thanks in advance,
Hylke

On 10/11/07, Rafał Kamraj <[EMAIL PROTECTED]> wrote:
>
> Howdy Hylke
>
> First of all check if problem is with lib3ds or with your pipeline.
> So clear screen to white to actually see anything:
>
>         glClearColor( 1.f, 1.f, 1.f, 0.f );
>         glClear( GL_COLOR_BUFFER_BIT );
>
> then generate some normals by hand instead of using those from lib3ds:
>
>         void GenRandomNormals( float normals[], int n )
>                 {
>                         for( int i = 0; i < n; ++i )
>                                 {
>                                         float x, y, z;
>                                         do
>                                         {
>                                                 x = ( ( rand() % 2000 ) -
> 1000 ) * 0.001f;
>                                                 y = ( ( rand() % 2000 ) -
> 1000 ) * 0.001f;
>                                                 z = ( ( rand() % 2000 ) -
> 1000 ) * 0.001f;
>                                                 float l = (float)sqrtf(
> x*x + y*y + z*z );
>                                         } while( l <= 0.01f )
>
>                                         normals[i * 3] = x / l;
>                                         normals[i * 3 + 1] = y / l;
>                                         normals[i * 3 + 2] = z / l;
>                                 }
>                 }
> And put them into your vbuffer.
> If object is still black then problem lies in pipeline, maybe you forgot
> about enabling something?
>
> Greets
> Kefrens
>
>
>
>
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems?  Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >> http://get.splunk.com/
> _______________________________________________
> lib3ds-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/lib3ds-devel
>
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
lib3ds-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/lib3ds-devel

Reply via email to