Howdy Bart

Bart De Lathouwer pisze:
How would you recommend removing a mesh (and corresponding node)

Simplest solution is just not draw such mesh at all. :-)

 
For answer 3, what is the best way to order the meshes: in a seperate array - or inside the 3ds structures? Should I sort anything else than meshes? I guess i'm after a best practice here.
I usually create display list for mesh, then for each mesh I keep very simple struct like this:

struct SimpleRenderingMesh
{
    GLuint displayList;
    Lib3dsNode* node;
};

Then I can keep such structures in any way convenient. And draw them in any order I need.

I understand that the code to sort the meshes is not part of lib3ds perse, but is there a list of related functions avail? (eg to sort meshes for transparency)
You should determine distance of mesh from camera, then order meshes by their distances. Actually you just need to sort transparent meshes, opaque meshes order is not important.


To find mentioned distance there are at least two methods which come to my mind:
M1. simple calculating distance between two points:
    for each mesh:
        Point3 distVec = mesh->center - camera->position;
        float distance = distVec.Length();

M2. signed distance from view plane:
     for each mesh:
        float distance = ( mesh->center - camera->position ) * camera->viewVect; /// * is for dot_product

"mesh->center" is actually translation taken from node's matrix: x = matrix[3][0], y = matrix[3][1], z = matrix[3][2];


To sort things out, there are many methods available, try googling for them.
In plain "C" you may use "qsort" defined in header <cstdlib> to sort any table by any criteria,
with C++ you may use "sort" from standard header <algorithm> but that's the other story.


BTW, my material is not transparent because of the transparency parameter in material, but because the texture contains an alpha channel. I think i can treat it in the same way as you discribe below, correct?
that's right. transparency may be defined on vertices of mesh or by alpha channel in texture.



Well, hope that helps :-)
Greetings
Rafal

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
lib3ds-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/lib3ds-devel

Reply via email to