清华BBS在教育网内可以用bbs.tsinghua.edu.cn访问,教育网外不知道可否.
torry有一个程序可以将3DS文件的所有信息读出来,并用OpenGL显示出来,你
可以看看.
http://www.torry.ru/
Opener, the 3DS file reader
---------------------------
WHAT IS IT FOR?
Opener is mainly a sample implementation for the 3DS import library for Delphi I wrote. Meanwhile, though, it has been so much enhanced it cannot be considered any longer as simple demonstration program (~24.000 lines of code including the 3DS library). Instead it competes directly with other viewers like View3ds which it lefts behind in all aspects. Apart from features not (yet) supported by OpenGL (which is used to render 3DS objects to the screen) almost all 3DS features are used as far as possible.
SUPPORTED FEATURES
- Loading of all information available from a *.3ds file. If I say all then I mean all. Don't fiddle around with unknown or badly documented chunks. Instead use the provided "database" structure (a structure consisting of many lists and records) to get hold of anything you like. This includes among much other:
- global settings like versions, background, atmosphere, mesh settings, viewport settings
- mesh data like: options (e.g. visible lofter), vertex data, texture data, mapping icon information
- omni and spot lights
- materials data like: options (e.g. additive transparency), colors, shininess, transparency etc., map settings for all maps used in a *.3ds file (texture 1 and 2, opacity, bump, specularity, shininess, self illumination, reflection)
- cameras
- detailed view of the chunk structure (just for reference, you don't need this)
- keyframer data for all object types (spline values, position and color keys etc.)
- An OpenGL viewer using as much as possible data from a *.3ds file to display it. This includes:
- a very effective algorithm to compute normal vectors from smoothing groups (no implied average angles needed)
- solid, gradient and bitmap backround
- fog
- textures with auto scaling, so they don't need to be a power of 2 in size (supported files are: jpg, tga, gif, bmp, pcx, bw, rgb, cel, pic)
- auto centering of meshs
- blending
- line and fill polygon modes
- direct and spot lights
- an improved camera model using focal length for zoom
- hierarchical models using keyframer data (including multiple instances of a mesh etc.)
- One Delphi class (TFile3ds) exposes all data of a *.3ds file using a few lists and supports loading from a stream as well.
- Bonus unit included which contains many needed vector, matrix and quaternion functions (Geometry.pas).
- Freeware DLL included to enable import of tga, gif, pcx and jpg files (NViewLib.DLL). If this DLL is not available then jpg, tga, gif and pcx files cannot be used by Opener.
- Global texture path as well as a MRU list for already seen 3ds files is implemented (using a simple *.ini file in the application's directory).
- File drop aware application
LIMITATIONS
- The user interface of Opener is somewhat overloaded due to the huge amount of information to be displayed. The program has furter limitations like being not sizable due to the overall layout which needs a specific minimal space.
- Visible Lofter, matte object, cast/receive shadows, icon mapping and box mapping are not used in OpenGL display.
- Light source exclusion and attenuation are not used in OpenGL display as well as visible cone and projector for spot lights.
- Cameras are totally ignored and instead an own camera handling is implemented.
- Many of the material properties are not used for rendering as they don't have an equivalent in OpenGL (yet). Only one texture image (Texture 1), colors, shininess, transparency and two sided rendering values are taken into account.
- Keyframer data (placing, rotation etc.) for light sources and cameras is ignored.
- Animation using keyframer data is not implemented.
- Although material transparency is implemented it produces sometimes strange results because for a properly working implementation all polygon meshs would have to be sorted from farthest to nearest (which isn't done in Opener).
- Transparent meshs will still hide those parts of meshs which are further away (depth testing). One could disable depth testing while drawing transparent meshs but this produces other even stranger results.
- SXP, IFL and TIF texture files will not be loaded.
- depth cueing atmosphere is not supported, layer fog is handled as normal fog
- There's a problem with face winding in some models. Sometimes parts of a mesh seems to be stored with the opposite face winding than the rest of the model. I have not found any indication telling this reversed order, so I cannot set it correctly.
- I have not found a rule when to use texture modulation. As this depends on the material color it happens sometimes that parts of a mesh appear very dark (if its diffuse color is nearly black) although they are textured and should display in decal mode.
These limitations concern only the application and the OpenGL viewer implementation. The import library still exports all available data.
OTHER ISSUES
Some *.3ds models include huge extents (45.000 and more units) while usual extents reach from 1 to 100 units. Since the depth buffer looses precision the larger the view range is (near plane - far plane distance) I nailed down the view range (also called: depth of view) to 1000 units, which may result in not visible meshs as they are clipped at this boundary. On the other hand 1000 is a quite high value and may result in socalled depth fighting if depth values of different meshs are relatively near together.
COPYRIGHT
The program "Opener" as well as all included source code (the import library) is freeware for any usage as long as my reference (titel, name, eMail address, copyright) remains in the source and I'm given proper credit in each application the import library is used. I do still keep all rights on this software and may not be charged for any failure or problem arising from its usage.
And now have fun and
Mike Lischke