Viggen's 3D Design concept

 

Generally, Plane Maker (PM) is powerful enough to produce good-looking aircrafts for X-Plane. However the SAAB JA37 Viggen is too complex to be built with classic methods. Going beyond acf’s 3d limitation has always been an important turning point in order to achieve the Viggen and make a real breakthrough in design field for X-Plane.

 

Why Plane Maker is not sufficient?

1- Plane Maker 3d tools are poor in front of specialized stand-alone 3d software such as Blender, Max, Ligthwave, Rhino or others.

2- 3D modelling through Plane Maker is limited by acf’s structure itself and subsequently 3d evolution is X-Plane dependant.

For example with an ACF, asymmetric bodies are prohibited, max number of stations per body is of 20, max number of vertices per section is only of 18 and UV map customization is not possible with PM7.

 

Thus, our idea for the Viggen was to use a hybrid construction mixing a high detailed OBJ mesh having the look of the Viggen with a partially invisible ACF to simulate flight characteristics.

This approach let us produce accurate aircraft without any technical restriction by using powerful stand alone 3d software to shape the OBJ instead of Plane Maker.

 

How to do that?

The trick is in using a plug-in (called X-Airframe) to display the OBJ in X-plane over acf’s centre of gravity (CG).

Then it’s a matter of doing a subtle combination between the parts of the acf that stay visible and the shape of the OBJ.

With the introduction of XP8.20 we can now bypass the plug-in and directly use the aircraft_cockpit object in OBJ8 format. 

 

This is the originality and the strength of the new Viggen for XP8 we have built.

In one hand, we have kept the acf to its single role of aerodynamic frame base determining how the aircraft behave in simulator condition.

In the other hand, high detailed 3d look is allocated to an OBJ7 (and now an OBJ8) mesh but that does not interact with X-Plane’s aerodynamic universe.

 

X-Airframe

 

Plug in description (for XP7.xx to XP8.17)

 

Manu coded the first prototype of the plug with Visual Studio 6 (c/c++) during the early period of X-plane 750.

The original code is stemming from Goodway Team’s X-cockpit and X-Pushback plug-in.

X-airframe routine uses a little of x-plane’s SDK instructions but a large scale of Open GL library making multiplatform compatibility harder to code.

 

X-Airframe plug-in is basically designed to display and centre the OBJ7 of your choice on acf’s centre of gravity (CG)

When activated, X-Airframe’s user interface lets you change freely (with num key pad) OBJ’s coordinates offset around the CG. Thus you can adjust the fuselage location easily.

X-Airframe is not exclusive to the Viggen. You can use it with any type of 3d model of your own creation, as long as you do respect naming convention described below.

 

 

 

 

                                                                                                                                       

    Fig:X-airframe user interface and Viggen’s Beta                                                         Fig:X-Airframe is not exclusive to the Viggen.

                                                                                                                                 Here a Lockheed F104G mesh

 

 

X-Airframe is pretty comparable in its functioning to the “aircraft_cockpit.obj” seen in latest version of XP7 and the newest XP8.

However X-Airframe is compatible with ALL version of X-Plane 7&8 and improves 3d rendering of OBJ7 meshes built with Ben Supnik’s OBJconverter.

 

X-Airframe system file is designed to work with very limited resources. To let X-Airframe run a new 3D model, you have to provide different files.

All 3D files must be located in the aircraft folder of your choice. Naming conventions ARE NOT "X-Plane style" yet.

 

-x.obj: Object’s 3D data structure in OBJ7 file format. OBJ7 structure should be made with TRI type primitives ONLY (QUAD is not supported)! You can do that by using Ben Supnik OBJ converter.

-x.bmp: Texture’s sizes are 256x256 multiple, max is 2048x2048 resolution; Magenta (R=255; V=0; B=255) is set as default transparent colour; Apple green is half transparent colour.

-x.nml: Normals orientation data structure file for smooth shaded rendering of OBJ7 in X-plane

This file is auto generated by the plug when you first launch X-plane with a new 3d model.

Time of nml construction varies according to your computer performance and the number of polygons of the OBJ7.

It can be terribly long due to little optimization with the code. For example with the 180kpolygons of the Viggen (a monster!) and an Athlon XP2400+, the plug needs 45 minutes in order to generate the NML. Once the NML file is definitely created, X-plane’s extra time loading is negligible.

 

Known issues

 

-Reloading a new OBJ in the same X-Plane session will not work. You have to quit X-plane before loading a new type of x.OBJ.

-As I am writing these lines X-Airframe plug-in is Windows only compatible, but the team is working hard to make it compatible with other platforms.

 

X-Airframe, OBJ7 and smooth shading

 

This section explains why we use a plug-in for X-Plane 7.xx to XP8.17 instead of the aircraft_cockpit.obj

It gives also technical information about how the plug in works behind the scene.

 

What is smooth shading and flat shading?

 

Smooth shading is a technique used in 3d rendering to create the appearance of curved surfaces rather than flat, faceted sides.

 

With 3d objects, a Normal (or perpendicular vector) can be associated not only with the flat surfaces of the polygons, but also with the individual points that make up the vertices where polygons meet on the surface of a model.

Such vertex Normal can be directly assigned in the model file (rare), but are usually computed during rendering by averaging the Normals of the adjacent polygons.

Failing to give this vector alongside the surface definition itself makes OpenGL renders a uniformly lighten object. That is the flat shading rendering.

To produce an even more aesthetic enlightenment, you must give to OpenGL, one normal vector per surface’s vertex. The result is better looking and is known as smooth shading rendering.

 

The computation for smooth shading uses the Gouraud interpolation (from the name of the French engineer who invented it in the 70’s).

Because each vertex has its own normal, the lighting model computes a different colour for each vertex. The interpolation then calculates colours for each pixel in the polygon that vary smoothly across the polygon interior, providing a smooth colour graduation across the polygon.

 

Fig: Flat shading versus Smooth shading

 

OBJconverter conversion drawback with smooth shading

 

Each type of OBJ7’s primitive doesn’t process shading the same way.

All OBJ7 primitives are listed below with a short description and how they deal with smooth shading in X-plane.

 

- TRI: triples of vertices interpreted as a single triangle (flat shaded).

- QUAD: quadruples of vertices interpretedfour-sided polygons (flat shaded)

- TRI STRIP: linked strip of triangles (smooth shaded).          

- TRI FAN: A series of triangles that all share a single vertex, forming a fan-like structure (smooth shaded).

- QUAD STRIP: A series of quads joined at the edges (smooth shaded).

 

Generally you may want to convert a mesh for X-plane scenery or 3d cockpit by using Ben Supnik’s OBJconverter utility tool…it is the simplest way.

 

1- Run Objconverter and set “save as OBJ7”.

2- Drag and drop your 3d source (3ds or VRML2.0) inside the window.

3- Your new obj7 is now available.

4- If you want to use it with X-Airframe then rename it x.obj. No need to edit the x.obj with a text editor to assign textures for X-Airframe. The plug-in will seek automatically for the x.bmp texture map in the same folder.

 

You are done!

Fig :OBJconverter interface

 

However OBJconverter import/export works simply and this can cause trouble with final rendering in X-Plane:

 

During conversion into OBJ7 file format the data structure of the input 3D source is extremely simplified.

All polygons of the original 3ds or VRML source are tessellated into a set of TRI primitives ONLY.

OBJconverter doesn’t import smooth data group from the 3D source and does not optimize the output mesh by using FAN and STRIP primitive that indicate smooth shading to X-Plane’s Open GL 3d engine.  

As a consequence the final OBJ7 output is flat shaded instead of the smooth shading expected.

The disadvantage of flat shading is that it gives models a facetted look.

 

                         

 

  ig: A sphere displayed in X-Plane7 without X-Airframe…                                            Fig: The same but with X-Airframe running. Smooth shaded.

  Note the flat shaded rendering.

 

 

X-Airframe shader

 

In order to bring a solution to this problem, Emmanuel Hairault (aka Manu) has coded a special sub-routine with X-airframe that allows smooth shading even with TRI made OBJ7.

 

How does it work?

The routine checks if the coordinates of each vertex of a TRI match with coordinates of adjacent TRI’s vertices.

If TRUE, then it is assumed that the vertex meets one or more adjacent polygons and that smooth shading should be applied there.

 

A Normal vector per vertex is then computed, averaging Normal of adjacent surfaces.

Result is stored in the NML file (auto generated) by the order in which the vertices of the TRI polygons are listed.

 

The process is repeated for all TRI vertices. Therefore the more you have vertices the more it takes time to compute.

 

Data stored in the final NML file are used to force smooth shading rendering in X-Plane.

 

Viggen XP8.20: plug less version

 

The plug less version of the Viggen for XP8.20 is currently under development and beta release is planned for X-mas 2005.

 

Since xp8.20 and the introduction of OBJ8 file format, the X-Airframe plug-in is partly useless (but still operational).

This statement doesn’t sign X-Airframe death warrant. The plug is still extremely useful and powerful with XP7 and XP8 up to XP8.17 version.

 

OBJ8 aircraft_cockpit

 

The file structure of the new OBJ8 format for XP8.20+ offers a larger array of options than the former OBJ7 format. We can now have smooth shade data groups, double side display, animation data ref and variable level of detail depending on distance.

 

Conversion to OBJ8 file format from other 3d source file is also made easier thanks to Jonathan Harris plug-in for Blender ( http://blender.org/cms/Home.2.0.html )

Xplane2Blender plug-in is extremely powerful and it can export textures, animation and shading data group in OBJ8.

Therefore with XP8.20+ we can now use a smooth shaded “aircraft_cockpit.obj”, which is part of default X-Plane 8’s features, instead of OBJ7+x-airframe technology.

 

There is no difference in the graphic result between the plug and the plug less version of the Viggen in X-Plane 8.20.

 

However the procedure to create an operational smooth shaded OBJ8 is slightly more difficult to achieve than with OBJ7+X-Airframe technology.

 

OBJ8 step-by-step creation procedure should be as following.

 

1- Use your original 3ds or VRML2.0 source with your favourite 3d software and convert it into a Wavefont file format (extension is *.obj…but don’t mess with OBJ file extension for x-plane!!)  and save also texture data structure (*.mtl file).

 

2- Import the Wavefont file into blender with the Wavefont import/export Python script (available here http://lodweb.free.fr/downloads/python/obj_io_modif232.py. Check also the home page for extra tips  http://lodweb.chez-alice.fr/tuts/blender/)

 

3- Set on smooth shading for all parts of the 3d model, force double side display in the edit texture window and add animation frame if you wish.

 

4- Save the result into OBJ8 file format thanks to Jonhatan Harris’s X-Plane2Blender plug –in ( http://www.marginal.org.uk/x-planescenery/ )

 

5- Rename the OBJ8: Aircraftname_cockpit.obj. Edit the file with a text editor to assign texture file (texturename.png) and controls for animation

 

You are done!

Fig: Viggen in Blender before saving it in OBJ8

 

 

 

 

 

Viggen's 3d modelling

 

Modelling of the Viggen for X-plane followed an 8 steps procedure

 

1- Documentation

Searching for information about the Viggen has been a long and continuous task.

Technical data, scale plans, high-resolution photography and 3 views blueprints are major factors in determining 3d modelling accuracy.

Thanks to Erik relationships with in-house FMV and SAAB personnel we have obtained rare declassified data and photos.

Internet was also a free and rich database. More than 600 screens of the Viggen were collected, but just few of them were really useful to help us with 3d design.

Special credits goes also to Per Norberg who has obtained from Swedish air force Museum in Linköping the authorisation to climb on Viggen 01’s wing for some exceptional shots.

 

 

2- Nurbs modelling

From the first drawing to the final model of the Viggen, we have built a grand total of 51 step versions.

The original Viggen was built with Rh.i.no, a Nurbs based 3d software that provides semi-professional modelling tools and can generate extremely smooth and precise shape (if you are skilled enough;)).

Nurbs (for Non Uniform Rational B-Splines) 3d software can build smoother model than polygonal modeller. This is possible thanks to a math description of curves and surface instead of a classic mesh. For example a sphere is described by a combination of three circles instead of hundreds quadratic surface coordinates.

This is called “Spline based” modelling and refers to “Spline” curves. A Spline is a (usually curved) line that is defined by control points.

This makes it possible to edit curved shapes by manipulating curves with control points, rather than pushing around vertex points and polygons.

 

Fig: Viggen’s construction using Nurbs modelling

OBJ7 model unit is given in meter, therefore the Viggen model is scaled with values that reflect a distance in meter whatever the reference unit tuned in the 3D software.

 

3- Tessellation

Literally it means to form or arrange small squares in a “chequered” or mosaic pattern.

Tessellation is needed to transform the Nurbs model into an editable polygonal mesh by the approximation of curved surfaces.

 

 

A tessellation of triangles is the most common in 3D CG.

 

A tessellation of triangles (TRI):                        

 

A tessellation of squares (QUAD):                                 

 

Fine-tuning of Tessellation parameters is important to determine how many polygons the 3d model will have.

For the Viggen (and although our efforts to reduce the count) we have reached 180k polygons. This figure gives you an idea of the level of detailed we have obtained for the Viggen

As a comparison a low poly ACF is only of 10k polygons.

The drawback is that only computers with relatively recent (12/2005 ;)) graphic cards can display such a fat model in X-plane.

This is especially true with X-plane 7…X-Plane 8 3d engine is far more efficient.

Tests have shown that a computer equipped with an AMD Athlon 2400+, nforce2 chipset, 1Gb PC2700 ram and a Geforce 6600GT 128Mb is perfect for this task.

Fig: From Nurbs to OBJ7 conversion step by step

 

4- Polygonal optimization in Gmax

This concerns modelling corrections due to degenerated triangles after tessellation and includes:

 

- Remove co-planar polygons and isolated vertices.

- Set Normal per surface.

- Weld adjacent vertices for a smoother rendering.

- Reduce polygonal-count (as far as it is possible without messing the design).

                

 

Fig: Viggen in Gmax

 

5-UV Mapping

For the beta we have decided to produce a basic mapping that shows colours of Forsokcentralen FMV test centre.

UV map was achieved under Gmax. Photorealistic skins will be used in final production.

                     

Fig: Final mesh with basic mapping. 180k polygons!!!!                                                                        Fig: Viggen basic UV map

 

6- OBJ – ACF Hybridization preliminary work

OBJ7 doesn’t support animation. OBJ8 does, but experimentation is still in its embryonic stage.

Therefore animated bodies of the Viggen are taken in charge by movable body parts of the acf we have kept visible and make fit with the OBJ’s shape.

 

7- OBJ 7&8 Conversion for X-Plane

Final output format before conversion is VRML 2.0. It is stable and reliable with OBJconverter and can be easily transformed to Wavefont file format by using the appropriateness plug-in with your favourite 3d software.

Depending of the technology used (X-Airframe+OBJ7 or plug less OBJ8) the procedure to generate OBJ file is different. Details have already been given in previous sections.

 

8- Centring the OBJ

 

Viggen ACF's 3d design

 

From a certain point of view, using a stand alone 3D model in place of the acf lets think that the accuracy of acf’s shape is not any more an important matter…but this is wrong for 2 reasons.

 

1- Major flight characteristic in X-Plane such as drag, mass repartition and lift are determined by acf bodies and wings geometries.

2- In X-plane, only the acf can project a shadow on the ground. OBJ can’t.

 

Therefore we have paid a special attention to make the shape of the acf as close as possible to real Viggen although using the limited 3d resource of plane maker.

The original acf, initially created for XP730 in 2004, was retrofitted. Almost all the aspects from the nose to the exhaust were reshaped to conform to blueprints.

 

The main fuselage is a combining of 4 modules: Nose section, main cockpit section, dorsal edge and tail section

Similar construction has been adopted for main nacelle with 4 linked modules as well: 2 asymmetric inlets, engine nacelle and exhaust section

Creating such streams of bodies perfectly joined together increase the number of stations available for modeling and improve smoothness of the profile. 

 

Another difficult task was to create asymmetric bodies for inlet sections.

Asymmetric body is one of the major limitations of Plane Maker. However acf structure can be tweaked and pushed over its natural limits.

Stanislaw Pusep ACFtools 0.6 (http://sysd.org/xplane/acftools/index.php) is a perfect utility to text edit the acf and change the coordinates of vertices of each station to force body asymmetry in X-Plane.

However this task is especially hard to achieve. In addition the tweak is unstable and “Plane Maker sensitive”.

This means that if you try to open the “section” window of a tweaked Misc body in PM7&8 then symmetry will be restored automatically on the base of the left half profile.

For the Viggen MISC BODIES 1&2 are asymmetric, so EDITING them in Plane Maker IS NOT RECOMMENDED and at your own risk!

 

 

                 

Fig: Viggen’s acf. Not as complex as the Obj mesh but nevertheless accurate.                              Fig: Viggen’s acf Wireframe in Plane Maker

Here with texture and aircraft_cockpit.obj in X-Plane 750.                                              

 

Next evolution in design

 

The beta doesn’t represent the final 3d we want to do and 3 major upgrades are currently under progress.

 

1- Final UV map and photorealistic textures for both plug and plug less version of the Viggen are planned.

2- Animations: Canopy, gears doors. (Only for plug less version)

3- 3d panel with possible animations.

//Gregory Sainz