PDA

View Full Version : Delphi: Colors of an object loaded with 3ds-loader



OpenGLover
12-17-2008, 07:37 AM
Hello,

I was looking for a simple 3ds-loader and found some on the web and I tried to use it with an example 3ds object of a plant but till now i was not able to show it in the right way. There are no external texture files with the 3ds-file but the 3ds editors display the plant in different colors. With the loader everything keeps white and with lightsources only gray shades.

I can not figure out what is wrong and maybe it has something to do with an old openGL version. I don't want to use GLScene because i like to keep things simple and don't want to convert my project and base it on all these GLScene components.

The Plant 3ds (m_plnt5_cut.mesh.gz) :
Plant Page (http://www-c.inria.fr/gamma/download/affichage.php?dir=PLANTS/&name=m_plnt5_cut)

The simple Loader I use for Delphi:
Simple 3DS loader (ftp://212.12.27.180/dist/doc/!!!!NEWDOC/OpenGL/sulaco/projects.html)

The loader will display the plant in gray colors
(In the source put Cz := -30; and change the 3ds filename..)

If I load the plant for example in Milkshape 3D tool the pot is blue, the leaves are green and the earth in the pot is brown..

How to show this with a simple loader??

Thanks !!

_NK47
12-17-2008, 08:07 AM
3ds file stores material chunks. material chunks store information related to the object it is assigned to. f.e. leaf would have green color for surface and maybe a texture assigned to it. first problem is to read material chunk out correctly and store it. seconds problem is to change material ( glMaterial (http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/material.html) ) values before drawing the corresponding object.

psuedo code in C++ sorry:
setMaterial(0); // leaf == 0
renderSubset(0); // render leaf subset
setMaterial(1); // pot == 1
renderSubset(1; // render pot subset