I previously mentioned that I had implemented an extensibility model, and thought it useful to discuss an example of adding a simple model to earth orbit, as shown below in Figure 1 (further images of which are in the gallery).
Figure 1. Model added to earth orbit. Colonial Raptor model (based on new TV series) by Coxxon.
The "extra" is defined as a folder containing the following items:
- A model in XNB format. XNA has built-in content importers for .x and .fbx (2009.1) formats.
- An optional pair of textures for both diffuse and emissive textures. These are standard image files.
- An XML file defining the "extra", in this case as shown below in Listing 1.
<?xml version="1.0" encoding="utf-8"?>
name = object name
box = box for pick tests, normalized relative xyz size (currently not used)
size = maximum length, km
description = label text
specintensity = specular intensity, default 0.50 in app.config
specpower = specular power, default 10 in app.config
scale = scale factor to unit length, default 1
model = path to model .xnb file
texture = path to texture file
emissive = path to emmissive texture file
rotation = rotation = sidereal rotation period, days
<satellite name="raptor" box="1,1,1" size="0.0086" description="raptor" specintensity="0.1" specpower="10" scale="1" model="colrap1cox.xnb" texture="texture/colrap1cox.jpg" emissive="emissive/colrap1cox.jpg" rotation="1000" >
a = semi-major axis, km
e = eccentricity
w = argument of perifocus, degrees (aka longitude of perihelion, argument of perigee)
i = inclination to xy plane, degrees
node = longitude of ascending node, degrees
M = mean anomaly, degrees (J2000.0)
P = period, days
plane = orbital plane (Ecliptic, Equatorial, Laplace), default Ecliptic
<orbit a="6871" e="0" i="0" node="0" w="0" M="0" P="1000" plane="Equatorial" />
Listing 1. XML configuration file for satellite model "extra"
This configuration file specifies that the model should be added to the planetoid "earth" in the "solar" system, both of which are defined in system.xml configuration file.
In order to scale the model correctly, a scale factor is applied to normalize the model to unit length. This can either be applied in the XML scale attribute, or specified in the XNA content processor scale attribute, in which case the XML attribute can be set to 1. A size attribute then defines the maximum length of the model in km. The Colonial Raptor shown in Figure 1 was defined with a size of 8.6m.
The textures are defined in sub-folders "texture" and "emissive". If an emissive texture is not available, an all-black image (e.g. JPEG file) can be used.
The rotation period defines how long it takes for the model to rotate while orbiting the planetoid. If this is the same as the P orbital element, then the same face of the model is presented to the planetoid throughout the orbit. The remaining standard orbital elements specify that the model is in a circular equatorial orbit at an altitude of 500km (the earth has a radius of 6,371km).
The extra is included automatically when added to the /data/extras folder.