[too big tube PIC] M3G Chapter 4.5.   Using M3G File Models

 

[ This chapter does not appear in the book. ]

It's easy to load a model from an M3G file: call Loader.load(), and that's it, or is it?

What if you're not sure what the M3G file contains? Perhaps you only need a single 3D shape, embedded deep inside the scene graph? What if you need a reference to the shape's AnimationTrack or its Material? You need to examine the loaded scene graph to find those nodes.

[repositioned tube PIC] Even if you manage to get the model into your application, it may be incorrectly scaled, or positioned off in the heavens. You need an interactive way of adjusting the shape's size and location, and those adjustments should be used whenever the model is subsequently loaded.

The ViewM3G application loads an M3G file into a scene familiar from previous chapters: a floor showing a large green XZ grid, a blue background, with lighting. The camera is mobile, so the model can be viewed from different angles. More importantly, the model can be scaled and translated. The screenshot at the top of the page shows a massive tube loaded into ViewM3G, but in the next shot we've cut it down to size, and repositioned it. The scaling and translation values are shown in the top-right corner of the screen.

[tube examination PIC] The scaling and translation information displayed by ViewM3G can be utilized when loading the model into other applications, as we'll see later.

The other main component of ViewM3G is its examination of the loaded scene graph, printed to standard output. The screenshot on the right shows the report when tube.m3g is loaded.

This cascade of class names and numbers will be explained later. It shows, for example, that the tube is a skinned mesh with two Group nodes as joints.

 

Downloads


Navigation:


Dr. Andrew Davison
E-mail: ad@coe.psu.ac.th
Back to my home page