Major update of 3D libraries available

by abenedik 21. October 2011 22:50

I am really happy to announce that a new major release of Ab3d.Reader3ds and Ab3d.PowerToys libraries has been released.

The key features of this release are:

  • Added transparency sorting that prevents problems with transparent 3D objects in WPF.
  • Improved reading of some 3ds files.
  • Simplified animating camera rotations.
  • Added support for OrthographicCamera.
  • Improved commercial licensing code.

 

Before describing some of the key features in more details let me first give you the full list of changes.

Ab3d.Reader3ds v8.0:

  • Added support for simple transparency sorting that can prevent most of the problems with transparent objects. If the new IsTransparencySortingEnabled property is true (by default) the transparent objects are moved after non-transparent objects. For complex models with many transparent objects use of advanced transparency sorting in Ab3d.PowerToys is needed. Also added TransparentObjectsCount property to Reader3ds (so user can decide if he need to enable transparency sorting or not - with Ab3d.PowerToys).
  • Added NameFormatString to BaseXamlWriterSettings - it can be used to customize how the object names are written to XAML (custom prefixes and suffixes can be added to names).
  • Added possibility to read tga into BitmapImage with static Read method in a new Ab3d.Common.TgaReader class. Note: The previous versions of Reader3ds already supported reading tga files. But it was not possible to read tga files in your applications. This is now possible and enabled you to convert tga images to common files (for example png) that can be used with xaml created from 3ds file). This feature is available only in pro version.
  • Fixed reading some of the objects with object matrix that has negative determinant.
  • Fixed using ForceTwoSidedMaterials property for models that does not have material defined and where the default material is used.
  • Fixed objects without material set (default material is used) and with object matrix that has negative determinant.
  • Fixed when object with negative determinant is broken into sub objects for different materials - the parent's negative determinant was not used before.
  • Fixed reading 3ds file where definition of two sided material is written outside material chunk.
  • Fixed reading some partially broken 3ds file (objects with invalid triangle indices are not shaded).
  • Skipped importing 3D objects that does not have triangle indices set (have only positions set).
  • Fixed security exception in partially trusted WPF Browser applications - before the multi-treading code was not able to get the number of processors on the system.
  • Improved commercial licensing code to prevent delay caused in RSACryptoServiceProvider under some circumstances.
  • Added Ab3d.Licensing.PowerToys.EmbeddedLicenseAssembly property to speed-up looking for embedded license key in commercial version.

Ab3d.PowerToys v3.0:

  • Added support for transparency sorting with new TransparencySorter and TransparencyHelper classes.
  • Simplified animating camera rotation with new StartRotation, StopRotation methods on SphericalCamera. There is also a new IsRotating properties. The MouseCameraController is also adjusted to suspend animated rotation while user rotates the camera with the mouse.
  • Added axes names to CameraAxisPanel. Also added IsAxisNameShown, XAxisColor, YAxisColor and ZAxisColor properties to CameraAxisPanel.
  • Added support for OrthographicCamera for all Ab3d.PowerToys Cameras. Added CameraType and CameraWidth properties to BaseCamera.
  • Greatly improved creating wireframe from existing 3D models - now it is much faster and uses much less memory.
  • Improved LinesUpdater - the lines that are removed from the visual tree are now free to be cleaned by garbage collection.
  • Added Reset and UnregisterLine methods to LinesUpdater to manually remove lines from LinesUpdater. This enables better manual control of the registered lines.
  • Improved measuring scene bounds in SceneCamera when transformations are used on Visual3D objects. Before the used transformations prevented the camera to correctly show the scene.
  • Fixed selecting cameras with mouse click on camera icon in Visual Studio 2010 designer.
  • Added GetCameraMatrixes to BaseCamera to get view and projection Matrix3D of the current camera.
  • Improved Ab3d.Utilities.Dumper class - Added GetTransformText and GetMatrix3DText methods and made GetMaterialText public. Also the GetModelInfoString method now also displays the Transformation details.
  • Improved commercial licensing code to prevent delay caused in RSACryptoServiceProvider under some circumstances.
  • Added Ab3d.Licensing.PowerToys.EmbeddedLicenseAssembly property to speed-up looking for embedded license key in commercial version.

 

TRANSPARENCY SORTING

WPF 3D can show transparent 3D objects. But to show them correctly, the transparent objects need to be defined after all the objects that are visible through them.

The following image shows the transparency problem in a simple 3D scene. Because the red boxes are defined after the semi-transparent GlassPlane they are not visible through the GlassPlane (the order of objects is visible in the right):

WPF 3D transparency problem

To solve the problem, the GlassPlane needs to be moved after the non-transparent objects. The following image is showing the correctly rendered scene.

Solved WPF 3D transparency problem

For cases when the number of transparent objects is not big and if the transparent objects are not positioned in 3D space one after another, the simple transparency sorting is usually enough to produce correct rendering in WPF 3D.

But simply moving transparent objects after non-transparent objects is not always enough. For example if transparent object A is visible through transparent object B, than B must be defined after A. The problem in this case occurs when the camera is rotated so that B is visible through A. Now B must be defined before A. To solve this problem correctly, firstly the transparent objects must be moved after non-transparent objects and than transparent objects must be sorted by their distance to the camera. The sorting must be done after the camera is changed.

As seen from the new features lists above, both Ab3d.Reader3ds and Ab3d.PowerToys now support transparency sorting.

Ab3d.Reader3ds can perform a simple transparency sorting by moving transparent objects after non-transparent objects. Transparency sorting is performed if the IsTransparencySortingEnabled is set to true (by default). It is also possible to get the number of transparent objects by the TransparentObjectsCount property. Ab3d.Reader3ds does not do any sorting by camera distance. For this the Ab3d.PowerToys library is needed.

With Ab3d.PowerToys library it is possible to perform simple transparency sorting and sorting by camera distance. TransparencySorter class can be used to perform simple transparency sorting or ByCameraDistance transparency sorting where the transparent objects are sorted by their distance to the camera.

Simple transparency sorting (moving transparent objects after non-transparent objects) can be done with the following line:

Ab3d.Utilities.TransparencySorter.SimpleSort(myModelsGroup);

When sorting by camera distance is used, the TransparencySorter can also automatically re-sort the objects when the camera is changed. To optimize the sorting it is possible to specify an angle that will tell how much the camera's direction must be changed when a new sort is preformed.

To perform transparency sorting by camera distance the following lines of code can be used:

private TransparencySorter _transparencySorter;
 
private void StartTransparencySorting()
{
    _transparencySorter = new TransparencySorter(_rootModel3DGroup, Camera1);
     
    // Re-sort on every 10 degrees change
    _transparencySorter.CameraAngleChange = 10; 
 
    // Do an initial sorting
    _transparencySorter.Sort();
 
    _transparencySorter.StartSortingOnCameraChanged();
}
 
private void StopTransparencySorting()
{
    if (_transparencySorter != null)
        _transparencySorter.StopSortingOnCameraChanged();
}

For more code samples see the samples that come with Ab3d.PowerToys library.

The following images show rendering of the objects before (left image) and after (right image) transparency sorting:

WPF 3D transparency problem

WPF 3D transparency problem

IMPROVED READING OF 3DS FILES IN AB3D.READER3DS

Ab3d.Reader3ds went through a big test with our bigger customer. Many real world 3ds files were used to test the accuracy of the reader. Because many test files were not created with 3D Studio Max or similar product, many of them were not correctly formatted (it was not possible to open them with 3D Studio Max). After some changes in Ab3d.Reader3ds mst of those "broken" 3ds file can now be read correctly. This made the library even better and proved its status as the best library for importing 3ds files.

IMPROVED COMMERCIAL LICENSING CODE

The last relase of Ab2d.ReaderSvg, Ab2d.ReaderWmf and ZoomPanel library already got improved commercial licensing code. The change fixed a potential issue with using RSACryptoServiceProvider that can lead to very long delays when checking the license key. This issue has been now fixed for Ab3d.Reader3ds and Ab3d.PowerToys. Because of this issue it is highly recommended to upgrade to the new version.

Additionally as with the 2D libraries it is now possible to set the EmbeddedLicenseAssembly property to speed up finding the embedded license key in the application.

To see more details about this change please see the blog post for the 2D libraries or check the new help files.

OTHER IMPORTANT AB3D.POWERTOYS IMPROVEMENTS

A very useful new features of the Ab3d.PowerToys library simplifies creating animated camera rotations. Before animated camera rotations were created with binding a DoubleAnimation to Heading property of the camera. But using DoubleAnimation has its drawback because it the animation locks the value of the Heading and therefore makes rotating the camera with the mouse impossible.

The new version now include the StartRotation and StopRotation methods that can be used to simply start the camera animation. The StartRotation method takes two parameters: the first is heading change per second, the second is attitude change per second. The best thing about this is that while the camera is animated with StartRotation method, user can still use the mouse to rotate the camera (during mouse rotation the animation is suspended). This way it is very easy to create great presentations of 3D models where the model is rotated and the used can still manually change the rotation with the mouse.

One of the very requested feature was also a support for OrthographicCamera. It is mostly used in technical applications where the ratios and parallel lines of the 3D objects need to be preserved. The OrthographicCamera is now also supported.

A very nice new feature is also that axis names are shown on the CameraAxisPanel (it shows the orientation of axis of the current scene).

A lot of work was also done to improve 3D lines. Now wireframes from existing 3D objects are created much faster and also use much less memory. Also the memory management of the 3D lines is greatly improved and enables user to have more control of the registered 3D lines.

 

With new features the development of applications with 3D content has become even easier.

WPF 3D is very capable of displaying 3D content for most needs of business applications. It also has many advantages over other platforms (DirectX, XNA). With WPF 3D, Ab3d.PowerToys and Ab3d.Reader3ds programming with 3D was never easier.

I would like to conclude with saying that in my opinion desktop applications will not just sink into oblivion. They will still have their big share with complex business applications that need to be very user friendly, need advanced user interfaces to simplify complex user processes or require lots of resources. Despite many (usually not developers but marketing driven) considerations, I believe that WPF is still the very best technology for writing such applications.

Tags:

Ab3d.PowerToys | Reader3ds