Tomas Rapkauskas | 1 Sep 2006 09:31
Picon

Problem with glCullFace(GL_BACK) in the player.c

Hello,

I have a 3ds model(http://195.14.170.84/test.zip) there
"culled" faces should be front side, not back.
( static void init(void)... glCullFace(GL_BACK); )

(Also I tested this model with 3d max.
  3D Max shows model fine )

player.c has code:
    if( mat->two_sided )
	glDisable(GL_CULL_FACE);
    else
	glEnable(GL_CULL_FACE);

I think that after glEnable(GL_CULL_FACE)
should be defined "culling" face side.

I was trying to eliminate this problem, but I had failed..

Changing glCullFace(GL_BACK) to the glCullFace(GL_FRONT)
http://195.14.170.84/test.zip model looks ok, but other models not.

Also I noticed that changing face points direction 
(player.c: for i = 2 i != -1; --i) also solves 
defined problem. 

Maybe it as any attribute in the material
which defines culling side?

(Continue reading)

Denis Taniguchi | 1 Sep 2006 15:59
Picon
Favicon

Problem getting the normal right in a simple cube.

Hi devs.all!

We started using lib3ds a couple of weeks ago, and we
are already able to import 3ds model into our engine.
However some faces of the models weren't with the
correct light effect. After some debugging we found
out that the normals weren't right.
So we decided to start with a simple cube, and see if
the normals were ok. Strangely, the model had 26
points. Why 26? Next, we decided to spend some time
looking at the face list:
       0    2    3  smoothing:2
       3    1    0  smoothing:2
       4    5    7  smoothing:4
       7    6    4  smoothing:4
       8    9   10  smoothing:8
      11   12   13  smoothing:8
       1   14    7  smoothing:10
       7   15    1  smoothing:10
      16   17   18  smoothing:20
      19   20   21  smoothing:20
--->  22    0   23  smoothing:40
      24    6   25  smoothing:40
The line with an arrow seemed odd to us since the
index 0 were reused in a face with a different normal
than face [0, 2, 3] and [3, 1, 0]. In fact, that's
where the real problem lies, since
lib3ds_mesh_calculate_normals will replace index 0
with the normal of the face [22, 0, 23], losing the
correct normal for face [0, 2, 3] and [3, 1, 0].
(Continue reading)

Rafał Kamraj | 2 Sep 2006 11:21
Picon
Favicon

Re: Problem getting the normal right in a simple cube.

Hi
That's very strange, Can you provide this specific 3ds for us?

Greets
Rafał Kamraj

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
Reed Hedges | 2 Sep 2006 23:23
Picon
Picon

Re: Problem getting the normal right in a simple cube.

Are you using a modelling program to create the cube and other models?
Which one?

Reed

On 9/2/06, Rafał Kamraj <kefrens <at> wp.pl> wrote:
> Hi
> That's very strange, Can you provide this specific 3ds for us?
>
> Greets
> Rafał Kamraj
>
>
> -------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> lib3ds-devel mailing list
> lib3ds-devel <at> lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/lib3ds-devel
>
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
lib3ds-devel mailing list
(Continue reading)

Kresimir Spes | 4 Sep 2006 14:56

3ds export

Hi guys,

I'm having problems exporting a simple mesh (vertices (xyzuv) and face indices). the code runs fine and the mesh is exported, but the file format seems invalid (So says blender and 3dsxmax), here's my code:

        Lib3dsFile* file=lib3ds_file_new();
        if (!file)
        {
            printf("can't create new 3ds file\n");
        }
        Lib3dsMaterial* mat=lib3ds_material_new();
        strcpy(mat->name,"drek_na_kvadrat");
        Lib3dsMesh* mesh=lib3ds_mesh_new("mapa_jebote");
        lib3ds_mesh_new_point_list(mesh,nv);
        lib3ds_mesh_new_texel_list(mesh, nv);
        lib3ds_mesh_new_face_list(mesh, ni/3);
        for (int i=0;i<nv;i++)
        {
            mesh->pointL[i].pos[0]=lv[i].x;
            mesh->pointL[i].pos[1]=lv[i].y;
            mesh->pointL[i].pos[2]=lv[i].z;
            mesh->texelL[i][0]=lv[i].u;
            mesh->texelL[i][1]=lv[i].v;
        }
        for (int i=0,j=0;i<ni;i+=3,j++)
        {
            strcpy(mesh->faceL[j].material,"drek_na_kvadrat");
            mesh->faceL[j].points[0]=lind[i];
            mesh->faceL[j].points[1]=lind[i+1];
            mesh->faceL[j].points[2]=lind[i+2];

        }
        lib3ds_file_insert_mesh(file,mesh);
        lib3ds_file_insert_material(file,mat);
        lib3ds_file_save(file,output);



--
---
Krešimir Špes
Cateia Games
Lead programmer
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
lib3ds-devel mailing list
lib3ds-devel@...
https://lists.sourceforge.net/lists/listinfo/lib3ds-devel
Denis Taniguchi | 4 Sep 2006 19:22
Picon
Favicon

Re: Problem getting the normal right in a simple cube.

Hi,

Thanks for the replies.
I'm using 3ds Max 8. I will try to test with Blender
and Maya also.
I'm attaching the simple cube model.
Regards!

Denis Taniguchi

--- Reed Hedges <reed@...> wrote:

> Are you using a modelling program to create the cube
> and other models?
> Which one?
> 
> Reed
> 
> 
> On 9/2/06, Rafał Kamraj <kefrens@...> wrote:
> > Hi
> > That's very strange, Can you provide this specific
> 3ds for us?
> >
> > Greets
> > Rafał Kamraj
> >
> >
> >
>
-------------------------------------------------------------------------
> > Using Tomcat but need to do more? Need to support
> web services, security?
> > Get stuff done quickly with pre-integrated
> technology to make your job easier
> > Download IBM WebSphere Application Server v.1.0.1
> based on Apache Geronimo
> >
>
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> > _______________________________________________
> > lib3ds-devel mailing list
> > lib3ds-devel@...
> >
>
https://lists.sourceforge.net/lists/listinfo/lib3ds-devel
> >
>
-------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support
> web services, security?
> Get stuff done quickly with pre-integrated
> technology to make your job easier
> Download IBM WebSphere Application Server v.1.0.1
> based on Apache Geronimo
>
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> lib3ds-devel mailing list
> lib3ds-devel@...
>
https://lists.sourceforge.net/lists/listinfo/lib3ds-devel
> 

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
Attachment (cube.3ds): application/octet-stream, 1250 bytes
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
lib3ds-devel mailing list
lib3ds-devel@...
https://lists.sourceforge.net/lists/listinfo/lib3ds-devel
Tom | 9 Sep 2006 14:26
Picon

Re: 3ds export

Hi,

Can you post your messages in ascii please ?

Anyway, if you try to export a 3ds with Blender, try this script :

http://dungeondigger.free.fr/divers/3ds_export.py

I modified the original script in order to add smooth groups, and other
little things. It works almost well for me.

--

-- 
Tom

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
Tomas Rapkauskas | 15 Sep 2006 20:13
Picon

Re: Mirroring mystery solved!

 >There's nothing wrong with what lib3ds itself is
 >doing, it's just the player's interpretation of the matrices that's
 >slightly lacking.

I don't agree on this. I think that this is lib3ds bug not player and
nodes matrices should automatically(maybe in the lib3ds_node_eval 
function), because:
1. Bounding box calculation depends on this bug fix also
( I can send a model where bounding box will be calculate incorrectly)
2. Such tools as 3ds2rib or 3ds2u should be updated
3. and many other developers should update their sources also

Tomas

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
SourceForge.net | 1 Sep 2006 09:20
Picon
Favicon

[ lib3ds-Patches-1550343 ] Possible memory leak in lib3ds_file_free() (fix bug 1462603

Patches item #1550343, was opened at 2006-09-01 10:20
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=304041&aid=1550343&group_id=4041

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Tomas Rapkauskas (slider666)
Assigned to: Nobody/Anonymous (nobody)
Summary: Possible memory leak in lib3ds_file_free() (fix bug 1462603 

Initial Comment:
Additional info:
http://sourceforge.net/mailarchive/forum.php?thread_id=10027089&forum_id=5465

Index: lib3ds/file.c
===================================================================
RCS file: /cvsroot/lib3ds/lib3ds/lib3ds/file.c,v
retrieving revision 1.24
diff -u -r1.24 file.c
--- lib3ds/file.c    1 Jun 2006 10:32:56 -0000    1.24
+++ lib3ds/file.c    8 Jun 2006 11:50:38 -0000
 <at>  <at>  -253,6 +253,8  <at>  <at> 
 {
   ASSERT(file);
   lib3ds_viewport_set_views(&file->viewport,0);
+  lib3ds_viewport_set_views(&file->viewport_keyf,0);
+
   {
     Lib3dsMaterial *p,*q;

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=304041&aid=1550343&group_id=4041

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
Rafał Kamraj | 19 Sep 2006 19:39
Picon
Favicon

Re: Problem getting the normal right in a simple cube.


Howdy Denis.

Sorry for answering so late, but i was on the vacations :-)

Problem:
Vertices normals are incorrectly calculated for "cube.3ds".

I investigated this and came to the following conclusion:

*Error with vertices normals calculation is inherited from 3DS format
itself.*

That's because in 3DS there is no separation between points indices and
uv indices.
Such separation of course is possible in modeller - 3DSMax: max's face
looks a bit like this:

class MaxFace
{
public:
    int points[3];
    int texCoords[3];
    unsigned int smoothing;
};

If for example in modeller(3DSMax) we have two faces with same smoothing
group and sharing two points but having different uv coordinates:
maxface0
    points = 0, 1, 2;
    texCoords = 0, 1, 2;
    smooth = 2;
maxface1
    points = 1, 0, 3;
    texCoords = 3, 4, 5;
    smooth = 2;

- such model will be incorrectly exported to old 3DS format. Exporter
will detect different texCoords and will duplicate shared points to get
"one point - one texCoord" situation:

3dsface0
    points = 0, 1, 2;
    smooth = 2;
3dsface1
    points = 4, 5, 3;
    smooth = 2;

with points 4 and 5 being clones of 1 and 0.

And because vertices normals may be smoothed only between same points
the lighting will be obviously incorrect.

Resolution:

Because of format shorthcomings we need additional post-loading
preprocess pass to recover informations lost during export to 3DS.
Suprisingly it's quite easy and possible.
First we need to introduce new "class Lib3dsFace2" with separate indices
for uv tex coords:

class Lib3dsFace2: public Lib3dsFace
{
public:
    Lib3dsWord texCoords[3];
};

second post-loading preprocess in three steps:

Step 1. Create new list of "Lib3dsFace2" and copy old "Lib3dsFace" faces
to this. Also to ensure correct texCoords indices we need to copy
"Lib3dsFace::points" to "Lib3dsFace2::texCoords".

Step 2. We need to identify duplicated points and then replace clones
with first original point:

    for( int i = 0; i < mesh->points; ++i )
        {
             if( processedPoints[i] )
                      continue;
            for( j = i + 1; j < mesh->points; ++j )
                {
                       if( processedPoints[j] )
                               continue;
#define EPSILON   0.01f
                       if( ( fabs( mesh->pointL[i][0] -
mesh->pointL[j][0] ) < EPSILON ) &&
                            ( fabs( mesh->pointL[i][1] -
mesh->pointL[j][1] ) < EPSILON ) &&
                            ( fabs( mesh->pointL[i][2] -
mesh->pointL[j][2] ) < EPSILON ) )
                            {
                                  ///  <at> todo: replace every occurence of
"j" point with "i"
                                  for( int k = 0; k < mesh->faces; ++k )
                                        for( int l = 0; l < 3; ++l )
                                              if(
mesh->faceL[k].points[l] == j )

mesh->faceL[k].points[l] = i;
                                  processedPoints[j] = true;
                            }
                }
        }

Step 3.
Calculate vertices normals, this time they will be correct.
<Code is too complicated to put here.>

Well, that's all folks. Sorry for being too bloated.
Hope that will help.

Rafał Kamraj

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

Gmane