[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.3.6 Hover

The mesh property class can be used to assign a 3D model to an entity. This property class defines a visual representation for an entity. This property class, defines a hovering object when used in conjunction with `pcmechobject'.

Property Class Details

General Information

A Hovering object can be something like a hovercraft or a anti-gravity ship. As well as hovering your object, it will also align it to the terrain, so that as it goes down a hill, the ship will also tilt.

This property class requires you to load it with an entity, which has a `pcmesh' property class to act as the terrain it hovers over.

Setting the Terrain

There are 2 ways to set the terrain mesh in `pchover':

This step is crucial, if you forget to do it the hovering system will not work.

Setting the Upthruster Function

Instead of using the default upthruster function, you may want to provide your own reactionary calculator.

 
// CEL Includes
#include "tools/stabiliser_dist.h"

class CustomUpthrusterFunction : public celStabiliserFunction
{
public:
  float Force(celHoverObjectInfo obj_info)
  {
    /* when the height of the object
        is less then 2, use an
        upthrust force of 8 */
    if (obj_info.height < 2)
      return 8.0;

    return 0.0;
  }
};

Then to insert into the property class you would do

 
pchover->SetStabiliserFunction (new CustomUpthrusterFunction ());

At runtime, everytime the objects iPcHover is updated, your upthruster function will get called with information with the objects information on its state.

 
struct celHoverObjectInfo
{
  /**
   * The height of the object above the
   * ground in along the world's y axis.
   */
  float height;

  /**
   * The vertical velocity of the object
   * along the objects local y axis.
   */
  float yvel;
};

angular correction

This refers to the object correcting its angle as it flies over terrain (facing downwards as it flies down hills).

The implementation of this is done by calculating the object's height at its center and then calculating the height away from the center. Using the differences in height and a bit of trigonmetry, you can see the angle of the object relative to the terrain.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]

This document was generated using texi2html 1.76.