Thanks for the prompt responds Rafal,
For question 1 I should have been more precize:
the scene that we render is for a virtual scene application. In order to
calibrate the scene, a big square was put in the 3ds (and in reality) to match
the whole. In normal circomstances, the square is removed from the real world
scene, and therefor should not be rendered. The easiest way to do this is to
remove the mesh for the wooden cube.
I'm doing so with my code below, but i have the impression that the corrupts
the 3ds.
How would you recommend removing a mesh (and corresponding node)
Thanks for answer 2, this is spot on :-) Thanks!
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 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)
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?
Thanks for looking into this Rafal
Kind regards
Bart
----- Original Message -----
From: kefrens
To: Discussion about lib3ds
Sent: Monday, January 26, 2009 10:34 PM
Subject: Re: [Lib3ds-devel] remove a mesh - relation mesh/node - meshordering
Bart De Lathouwer pisze:
Hi all,
Howdy Bart.
I have some questions while using lib3ds.
1) i'm successfull loading a 3ds model and rendering it. But the scene
contains calibration meshes, that do not need to be rendered in the final
image. I use
int index = lib3ds_file_mesh_by_name(m_pModel3dsFile, sMeshName);
if (index >= 0)
lib3ds_file_remove_mesh(m_pModel3dsFile, index);
to remove the mesh, but i believe this corrupts the model. What is the
correct way of removing a mesh (and the nodes - see my question #2)?
Never heard about "calibration meshes" but maybe you are talking about
"Dummies". "Dummy" is a node with attached empty mesh, it is used as camera
target or part of nodes hierarchy (bone in skeleton) used in animation. If so,
then you may easily detect dummy (from "player.c"):
if (node->type==LIB3DS_OBJECT_NODE) {
if (strcmp(node->name,"$$$DUMMY")==0) {
/* do something */
}
Then just skip it and don't render. I greatly discourage you to delete such
meshes, they may be necessary to proper animation of other objects.
2) what is the relation between the mesh and the node? Which is part or
relates to what? Can you recommend literature that makes me better understand?
(i bought some 3ds max books, but they dont even mention these words).
Appologies for this 101 question
Node is base for transformation in 3DS. There is always at least a "Root"
node in the scene. Other nodes are attached to Root. Each node may have
children nodes, so we can build hierarchy of nodes.
Node_Base -> Node_Middle -> Node_Top
Most important thing in node is it's transformation matrix, such matrix
describes node's transformations relative to it's parent node:
"node->matrix" is actually it's "local_to_parent" transformation, when we
want to get "local_to_world" we should do something like this:
/// this is pseudo-code, it may not compile, just explaining concept!
void CalculateNodesLocalToWorldMatrix( Lib3dsNode* node, Lib3dsMatrix& result
)
{
if( !node->parent )
{
memcpy( result, node->matrix, sizeof( Lib3dsMatrix ) );
}
else
{
Lib3dsMatrix parentToWorldMatrix;
CalculateNodesLocalToWorldMatrix( node->parent, parentToWorldMatrix );
MultiplyMatrices( node->matrix, parentToWorldMatrix, result );
}
}
So if we have following hierarchy:
Node_Base -> Node_Middle -> Node_Top
when we move Node_Base's position X by 5 units "Node_Base->matrix[3][0] +=
5;", then we will see that all nodes are moved by 5 units in X.
but when we translate Node_Middle by 5 "Node_Middle->matrix[3][0] += 5", then
only Node_Middle and Node_Top will be affected but Node_Base will stay in
position.
Each node may have an object attached. Such object may be light, mesh, dummy
or camera. So in short: nodes give transformation to objects to let the objects
keep interface clean and care only about lighting or being a mesh or camera or
dummy.
That's very sketchy and brief description. Look at "3DSMax SDK" for further
details.
3) how to i order the mesh/node/face so i can correctly render transparent
textures (textures with alpha channel) - do i order the mesh or the nodes.
(kinda like question #2).
Rendering transparent objects is always a pain. There is no simple and at the
same time correct method. For start you may take two pass method:
-first draw all your opaque objects with depth writing enabled;
-then disable depth write and render transparent objects sorted from farest
to nearest to camera;
this method may fail with not convex meshes or with special cases of
obstructions and intersections, but many games use such approach with success.
For example of loading and drawing a 3ds file see "player.c"
http://www.lib3ds.org/lib3ds-1.2.0/examples/player.c
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
------------------------------------------------------------------------------
No virus found in this incoming message.
Checked by AVG - http://www.avg.com
Version: 8.0.176 / Virus Database: 270.10.14/1920 - Release Date: 27/01/2009
18:15
------------------------------------------------------------------------------
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