/**
 * @file Types.h
 * @author Petr Egert (egertpet@fel.cvut.cz)
 * @brief Contains Vector3, WheelContactInfo, VehicleStatistics and VehicleControls structure declarations
 */

#ifndef TYPES_H
#define TYPES_H

#include <vector>

using std::vector;

namespace VRUT
{
    /**
     * @brief Structure representing a basic three component vector
     * @see vrut/trunk/core/3dmath.h for full implementation
     */
    struct Vector3
    {
        Vector3(){x = y = z = 0.0;}
        Vector3(float x, float y, float z) : x(x), y(y), z(z){}
        union
        {
            struct
            {
                float x, y, z;
            };
            float f[3];
        };
    };

    /**
     * @brief Structure representing wheel contact information
     * @see vrut/trunk/modules/VehicleSimulator/vehicle.h
     */
    struct WheelContactInfo
    {
        WheelContactInfo() {}
        WheelContactInfo(const Vector3 &p, const int i) : wheelPos(p), info(i) {}

        Vector3 wheelPos;
        int info;
    };

    /**
     * @brief Structure representing vehicle statistics
     * @see vrut/trunk/modules/VehicleSimulator/vehicle.h
     */
    struct VehicleStatistics
    {
        VehicleStatistics()
        :   velocity(0.0, 0.0, 0.0),
            angularVelocity(0.0, 0.0, 0.0),
            enginePower(0.0),
            engineRPM(0.0),
            wheelRPM(0.0),
            position(0.0, 0.0, 0.0),
            orientation(0.0, 0.0, 0.0),
            distance(0.0),
            range(0.0),
            charge(0)
        {
        }

        Vector3 velocity;           ///< Vehicle velocity
        Vector3 angularVelocity;    ///< Vehicle angular velocity

        float enginePower;  ///< Power of the engine
        float engineRPM;    ///< RPM of the engine
        float wheelRPM;     ///< Wheel RPM

        Vector3 position;       ///< Vehicle position
        Vector3 orientation;    ///< Vehicle orientation
        vector<WheelContactInfo> wheelContactInfo;  ///< Wheel contact information

        float distance; ///< Distance traveled
        float range;    ///< Range of drive
        float charge;   ///< Battery charge
    };

    /**
     * @brief Structure representing vehicle controls
     * @see vrut/trunk/modules/VehicleSimulator/vehicle.h
     */
    struct VehicleControls
    {
        VehicleControls() : gas(0.0), wheel(0.0), brake(0.0), coupling(0.0), gear(0.0){}

        float gas;      ///< Gas input of the vehicle (0.0 - 1.0 range)
        float wheel;    ///< Steering wheel input of the vehicle (-1.0 - 1.0 range)
        float brake;    ///< Brake input of the vehicle, (0.0 - 1.0 range)
        float coupling; ///< Coupling input of the vehicle (if any) (0.0 - 1.0 range)

        ///Gear enumeration
        enum {GEAR_BACK = -1, GEAR_NEUTRAL = 0, GEAR_1 = 1, GEAR_2 = 2, GEAR_3 = 3, GEAR_4 = 4, GEAR_5 = 5, GEAR_6 = 6};

        float gear;     ///< Gear currently used (should be int?)
    };
};

#endif // TYPES_H

