Ab3d.Reader3ds

Reader3ds is a class library than can be used to read 3D models from a 3ds file and to use them in a WPF (.Net 3.0) application. This way you can define 3D models in 3D modeling application and simply use the models in you application. The library can import much more complex 3ds files than Viewer3ds and online 3ds file converter. It also has many advanced options for importing 3ds file.


  3D modeling application 3ds file WPF application using Reader3ds

 

Overview

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 (see RobotArm sample).

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 (see Animator3ds sample).

Work with 3D content in WPF is now as simple as using gif or jpg images.

There is no need to create the models by hand. They can be created in almost any 3D modeling application. Call your design department to create one or simply get a model from one of many internet libraries. (For a list of free 3D modeling application and a list of some of the model libraries from internet see Links.)

 

Usage

When you have your model in 3ds file format, you can simply open it in your WPF application with the following code:

Ab3d.Reader3ds.Instance.ReadFile("my_3d_scene.3ds", Viewport1);

The code reads my_3d_scene.3ds file from the application folder and imports all the models, its materials and all the lights and adds them to the Viewport1. If there are any cameras defined in my_3d_scene.3ds the first camera is assigned to Viewport1. Simple as that!

After the file has been read you can access additional data about the 3D model. For example the following line gets the GeometryModel3D of the object that has name "head":

head = Ab3d.Reader3ds.Instance.NamedObject["head"] as GeometryModel3D;

The following line sets the Viewport's Camera to the second camera defined in 3ds file:

Viewport1.Camera = Ab3d.Reader3ds.Instance.Cameras[1];

Animation

The Reader3ds can also read the animation data from a 3ds file.

The easiest way to animate the objects is with the included Animator3ds helper class where you just specify the animation details like duration, auto reverse, etc. and call the DoAnimate method in Timer or Render event.

It is also possible to get data for each animation frame manually - even for the time between frames - for example for frame 1.5 - between the first and second frame. This way it is possible to create much smoother animations. For example if 3ds file defines 100 frames and you play it for 10 seconds that with showing just the actual frames it would be possible to show only 10 different frames per second. But with the possibility to get also the models and cameras between frames it is possible to show as many different frames as you wish.

Transformation and custom animation

Transformation and creation of custom animation is also simplified with the Transformer3ds helper class. The class provides methods to translate, rotate and scale all or just some of the read 3D objects. For example:

Ab3d.Reader3ds.Instance.Transformer.RotateObject("head",
      new AxisAngleRotation3D(new Vector3D(0, 1, 0), 10), true);

The above line applied the 10 degrees rotation around y axis to the "head" object. The last parameter (true) means that the rotation is additive. This means that the rotation does not replace the previous rotation but adds 10 degrees to it. This way it is very simple to create custom animations.

 

See Online help or help file included in the package for additional documentation and code samples.

 

The following sample applications with full source code are available:
Animator3ds
Animator3ds sample demonstrates how simple is to play 3D animations created in 3D modeling application and stored in 3ds file. The sample is using a new Ab3d.Animator3ds class that is part of Ab3d.Reader3ds library. There are two sample animations available.
 
RobotArm (Transformer3ds)
RobotArm sample demonstrates how simple is to manipulate with the read 3D model. The sample uses the Ab3d.Transformer3ds class (part of Ab3d.Reader3ds) to rotate, move, change materials, lights and cameras of the 3D model of robot arm.
 
Shading Sample
Shading sample with its complex 3D model pushes the WPF 3D engine to the limits. It also demonstrates the new Shading property of Ab3d.Reader3ds that defines how the Reader3ds library will apply shading to the read objects.
 
XAML Browser Application
XAML Browser Application sample demonstrates how it is possible to use all the power of Ab3d.Reader3ds library in the application hosted in web browser. The sample is a fully functional RobotArm sample that is slightly adapted for browser application.

 

 

DOWNLOAD All Ab3d tools, libraries and samples (3.29MB) [1 Jul 2008]
(Viewer3ds, Ab3d.Reader3ds, help file all sample applications)


System requirements:
Windows XP, Windows Vista (recommended)
.Net Framework 3.0 (also works with 3.5)
Visual Studio 2005 (can be imported into VS 2008) - for samples

 

 

Note: Subscribe to RSS feed to be informed about new content on the site.

Copyright © 2007 by Andrej Benedik. All Rights Reserved.