Difference between revisions of "Classic Elite ships wireframe"

From Elite Wiki
 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
In Classic Elite the ship geometries are limited to convex hulls to aid in rendering the wire-frame graphics as quickly as possible with hidden line removal. Each vertex is usually associated with 4 faces, each edge joining 2 vertices is associated with 2 faces. The maximum number of faces is 14, as is the case for the asteroid model. Face 15 is reserved to indicate a vertex is always visible regardless of the objection's orientation, e.g. more than 4 faces meet at that vertex. The (time consuming) 3D projection calculations for that vertex should always be performed, if the vertex is close enough to the player, else if the face is not visible then further tests are done to see if any visible face is associated with that vertex. An edge is only rendered if both faces associated with it are visible.
+
In Classic Elite the ship geometries are limited to convex hulls to aid in rendering the wire-frame graphics as quickly as possible with hidden line removal. Each vertex is usually associated with 4 faces, each edge joining 2 vertices is associated with 2 faces.
  +
  +
The maximum number of faces is 14+1, as is the case for the asteroid model. Counting from zero, Face 15 is reserved to indicate a vertex is always visible regardless of the objection's orientation, or more than 4 faces meet at that vertex. Otherwise at least 1 face associated with that vertex must be visible (its normal has a component pointing at the player) for that vertex to be considered further.
  +
  +
The (time consuming) 3D projection calculations for a visible vertex (associated with a visible face) are performed if the vertex is close enough to the player.
  +
  +
A line joining two vertices is only rendered if either of the two faces associated with it are visible, and the edge is close enough to be visible. The ship's data file design most ensure that any required vertices are already visible and have been projected.
   
 
== Ship data file format ==
 
== Ship data file format ==
Line 90: Line 90:
 
|}
 
|}
   
Each vertex has 6 bytes of data. Bytes X,Y,Z are the magnitudes. The signs for each axis are stored in bits 7,6,5 of Byte S. The lower 5 bits are a visibility distance, with a maximum value of 31 ensuring the vertex is processed for all distances until the ship is plotted as a large dot.
+
Each vertex has 6 bytes of data. Bytes X,Y,Z are the magnitudes of the 3D coordinate. The signs for each component are stored in bits 7,6,5 of Byte S. The lower 5 bits are a visibility distance, with a maximum value of 31 ensuring the vertex is processed for all distances until the ship is plotted as a large dot.
  +
The 4 faces associated with each vertex are stored in the 4 nibbles of Bytes F1 and F2.
 
{| class="wikitable"
 
{| class="wikitable"
 
! style="text-align:left;"| Byte X
 
! style="text-align:left;"| Byte X
Line 118: Line 118:
 
|...
 
|...
 
|||||||
 
|||||||
  +
|}
  +
  +
Each edge has 4 bytes of data. The visibility distance is stored in Byte V, with a maximum value of 31.
  +
The 2 faces associated with each edge are stored in the 2 nibbles of Byte F.
  +
Byte N1 contains the vertex id (*4) for one end of the line, Byte N2 the other end.
  +
  +
{| class="wikitable"
  +
! style="text-align:left;"| Byte V
  +
!| Byte F
  +
!| Byte N1
  +
!| Byte N2
  +
|-
  +
  +
|1F
  +
|19
  +
|00
  +
|04
  +
|-
  +
  +
|1F
  +
|29
  +
|04
  +
|08
  +
|-
  +
  +
|...
  +
|||||
  +
|}
  +
  +
Each face has 4 bytes of data.
  +
The signs for each normal component are stored in bits 7,6,5 of Byte S. The lower 5 bits are a visibility distance, with a maximum value of 31 ensuring the face is processed for all distances until the ship is plotted as a large dot. The magnitudes of the normal's 3 components are stored in Bytes X,Y,Z.
  +
  +
{| class="wikitable"
  +
! style="text-align:left;"| Byte S
  +
!| Byte X
  +
!| Byte Y
  +
!| Byte Z
  +
|-
  +
  +
|1C
  +
|00
  +
|18
  +
|06
  +
|-
  +
  +
|9F
  +
|22
  +
|00
  +
|0C
  +
|-
  +
  +
|...
  +
|||||
 
|}
 
|}
   

Latest revision as of 05:56, 10 June 2018

In Classic Elite the ship geometries are limited to convex hulls to aid in rendering the wire-frame graphics as quickly as possible with hidden line removal. Each vertex is usually associated with 4 faces, each edge joining 2 vertices is associated with 2 faces.

The maximum number of faces is 14+1, as is the case for the asteroid model. Counting from zero, Face 15 is reserved to indicate a vertex is always visible regardless of the objection's orientation, or more than 4 faces meet at that vertex. Otherwise at least 1 face associated with that vertex must be visible (its normal has a component pointing at the player) for that vertex to be considered further.

The (time consuming) 3D projection calculations for a visible vertex (associated with a visible face) are performed if the vertex is close enough to the player.

A line joining two vertices is only rendered if either of the two faces associated with it are visible, and the edge is close enough to be visible. The ship's data file design most ensure that any required vertices are already visible and have been projected.

Ship data file format

An initial header of 20 bytes is followed by the vertex data, in groups of 6 bytes, then the edge data in groups of 4 bytes, and finally the face normal data in groups of 4 bytes.

Byte (in Hex) Ship header information (example ship)
03 hi nibble is cargo type if scooped (0 is not scoopable). lo nibble is max pieces of debris if destroyed.
E9 lo byte of ship area for target hit decision
07 hi byte of ship area for target hit decision
86 lo byte of offset to edge data.
F2 lo byte of offset to face data.
5D maximum size of heap reserved for processed line plotting data (1+4*max visible edges)
00 vertex id for laser gun (*4), used for firing laser lines
1A number of vertices(*4 + 6), used for explosion dust origin(s)
72 number of vertices*6, used for vertex loop counter
1B number of edges
2C lo byte of bounty (in units of 0.1 Cr) if awarded
01 hi byte of bounty (in units of 0.1 Cr) if awarded
28 number of faces*4, used for face loop counter
1E distance away when wireframe rendering replaced by large dot
A0 Maximum ship energy
1E Maximum ship speed
00 hi byte of offset to edge data.
00 hi byte of offset to face data.
01 Scale factor for ship size when calculating whether face normal is visible
22 Laser firepower*8 plus maximum number (7) of missiles.

Each vertex has 6 bytes of data. Bytes X,Y,Z are the magnitudes of the 3D coordinate. The signs for each component are stored in bits 7,6,5 of Byte S. The lower 5 bits are a visibility distance, with a maximum value of 31 ensuring the vertex is processed for all distances until the ship is plotted as a large dot. The 4 faces associated with each vertex are stored in the 4 nibbles of Bytes F1 and F2.

Byte X Byte Y Byte Z Byte S Byte F1 Byte F2
00 0E 6C 5F 01 59
28 0E 04 FF 12 99
...

Each edge has 4 bytes of data. The visibility distance is stored in Byte V, with a maximum value of 31. The 2 faces associated with each edge are stored in the 2 nibbles of Byte F. Byte N1 contains the vertex id (*4) for one end of the line, Byte N2 the other end.

Byte V Byte F Byte N1 Byte N2
1F 19 00 04
1F 29 04 08
...

Each face has 4 bytes of data. The signs for each normal component are stored in bits 7,6,5 of Byte S. The lower 5 bits are a visibility distance, with a maximum value of 31 ensuring the face is processed for all distances until the ship is plotted as a large dot. The magnitudes of the normal's 3 components are stored in Bytes X,Y,Z.

Byte S Byte X Byte Y Byte Z
1C 00 18 06
9F 22 00 0C
...

Source code for the BBC tape and TUBE versions of BBC Elite can be found at Ian Bell's web site and were used to disassemble and interpret the Disk version described here.