by abenedik
4. December 2007 22:20
Programming with 3D objects has never been easier!
With Ab3d.Reader3ds library the models and animation data can be simply imported into WPF (.Net 3.0) application. The library adjusts the model data so they WPF applications they look as in the modeling application.
All the imported models can be accessed by their name (with NamedObject property) - as they were defined in 3D modeling application.
The integrated Transformer3ds class simplifies transformations on the objects - rotation, translation, scale. Creating custom animations can be done really easily.
Playing animations stored in 3ds file is also very simple. The Reader3ds has integrated Animator3ds helper class. The only thing to do is to set the duration of the animation or the number of frames played in a second and than calling the DoAnimate method in a Timer or Render event..
Work with 3D content in WPF is now as simple as using gif or jpg images.
The following image shows sample R2D2 model rendered without using smoothing groups (left) and with using them (right - new in v4.2) - some edges are sharp and some are smooth.
New in version 4.2:
- Support for smoothing groups - also automatically support flat and shaded models. This greatly improves rendering quality.
- Added Shading property to define None, Flat, Smooth or SmoothingGroups shading. Default value is SmoothingGroups that uses the Smoothing Groups values stored in 3ds file to define which edges are smooth and which are flat. This option produces the results as in the 3d model designer. However if you wish to force the flat or smooth looking objects choose either Flat or Smooth (before reading the 3ds file). Also if performance is much more important than rendering quality choose None.
- GetFrame can now get a frameNo as double to render the models between frames (for smoother animation)
- Fixed bug when reading from reasource and 3ds file contains texture files (exception was thrown).
- Also now it is possible to set TexturesPath property to url of the textures (http://...) or to the application resources ("pack://application:,,,/XAMLBrowserApplication1;component/models")
- Added GetCameraForFrame method that gets the camera for the desired frame number - this enables creating animated cameras
- Fixed reading material colors for some older 3ds files (in previous version reading crashed with "Non-negative number required." exception)
- The previous version has wrongly convert position from 3ds coordinate system to wpf coordinate system. The difference is that the x axis now points to the right instead of the left and the z axis points to the viewer and not away from it. This version by default uses new coordinate system, but if your application depends on the old one, you can simple set this property to true. But note that this can only be a temporary solution. Set UseOldCoordinateAxis property to true to use old coordinate axis.
- Added Materials property - Dictionary that can be used to access all the materials defined in 3ds by their name.
- Added support for animated lights (PointLight - positin, color; SpotLights - position, direction, color)
- Added GetExpirationDate method
- Added TargetViewport - gets the viewport that was used in ReadFile
- Added Animator3ds - helper class to simplify playing animations stored in 3ds file
Changes and fixes in Transformer3ds:
- Fixed isAditive parameter for Scale and Translate transform
- ObjectName can be now also Model3DGroup and not only Model3DGeometry
- RotateObjects can now be called with RotateTransform3D - this enables setting custom center of rotation (instead of center of object)
- Added methods without object name - to translate, rotate and scale all the objects and lights (as using constant Ab3d.Reader3ds.RootModelGroupName for objectName).
- Added Transformer property to Reader3ds - this simplifies transforming the read objects
Reader3ds, four sample applications, help file and Viewer3sd are available from www.ab4d.com/Reader3ds.aspx.