Project Universal Cars for Orbiter (UCFO) Development Thread

I'm no valgrind expert, nor a linux developer, but the output of valgrind seems more like telling you that there's a memory-leak (one has constructed an object with "new", but that object is never released - with "delete").
As ther's no delete, valgrind cannot tell you where that is missing - it can only help you by telling what created object is still not released at programm end.

That should of course be fixed, but has most likely nothing to do with the non-working of the animation(s).
Thanks for the info, I'll fix it.
It certainly is because the damn animations still don't work. Even after having fixed a little problem with the MGROUP_* structures, which are now created dynamically.
 
I think I'll port GeneralVehicle (not to release it for Linux, but to experiment with its code) and see how fred18's animation implementation works.
 
Only when I press the 1/3 keys.
I'll try your suggestion.

EDIT:
Valgrind tells me that the problem is in how I define the animations (correct me if I'm wrong):
Code:
==35813== 8 bytes in 1 blocks are still reachable in loss record 242 of 48,264
==35813==    at 0x4846613: operator new[](unsigned long) (vg_replace_malloc.c:729)
==35813==    by 0x3676A2: Vessel::AddAnimationComponent(unsigned int, double, double, MGROUP_TRANSFORM*, ANIMATIONCOMP*) (in /home/matias/orbiter_test/Orbiter/Orbiter)
==35813==    by 0x370060: VESSEL::AddAnimationComponent(unsigned int, double, double, MGROUP_TRANSFORM*, void*) const (in /home/matias/orbiter_test/Orbiter/Orbiter)
==35813==    by 0x1633BEDD: UCFO::DefineAnimations() (main.cpp:407)
==35813==    by 0x1633D5B7: UCFO::clbkSetClassCaps(void*) (main.cpp:711)
==35813==    by 0x346AC3: Vessel::SetClassCaps(std::basic_ifstream<char, std::char_traits<char> >&) (in /home/matias/orbiter_test/Orbiter/Orbiter)
==35813==    by 0x346377: Vessel::Vessel(PlanetarySystem const*, char const*, char const*, std::basic_ifstream<char, std::char_traits<char> >&) (in /home/matias/orbiter_test/Orbiter/Orbiter)
==35813==    by 0x2ED94B: PlanetarySystem::InitState(char const*) (in /home/matias/orbiter_test/Orbiter/Orbiter)
==35813==    by 0x2D8625: Orbiter::StartSession(Config*, char const*) (in /home/matias/orbiter_test/Orbiter/Orbiter)
==35813==    by 0x2D830B: Orbiter::Launch(char const*) (in /home/matias/orbiter_test/Orbiter/Orbiter)
==35813==    by 0x302B22: DlgLaunchpad::DrawScenarios() (in /home/matias/orbiter_test/Orbiter/Orbiter)
==35813==    by 0x3028A4: DlgLaunchpad::Show() (in /home/matias/orbiter_test/Orbiter/Orbiter)

And it refers to these lines:

C++:
ANIMATIONCOMPONENT_HANDLE flw_parent1 = AddAnimationComponent(anim_left_front_wheel_steer, 0, 1, &left_front_wheel_steer);

    ANIMATIONCOMPONENT_HANDLE flw_parent2 = AddAnimationComponent(anim_left_front_wheel_travel, 0, 1,&left_front_wheel_travel, flw_parent1);

    AddAnimationComponent(anim_left_front_wheel_rotation, 0, 1, &left_front_wheel_rotate, flw_parent2);

In fact, none of the wheel animations work.
Did you initialize the animation states?
 
Did you initialize the animation states?
Yes, here is my constructor:

C++:
//Constructor
UCFO::UCFO(OBJHANDLE hVessel, int flightmodel) :
VESSEL4(hVessel, flightmodel){

    mhUCFO = NULL;

    vhUCFO = NULL;

    mhcockpitUCFO = NULL;

    front_left_wheel_id = 0;

    front_right_wheel_id = 0;

    rear_right_wheel_id = 0;

    rear_left_wheel_id = 0;

    steering_wheel_id = 0;

    msg1 = NULL;

    msg2 = NULL;
    
    msg3 = NULL;
    
    msg4 = NULL;
    
    msg5 = NULL;
    
    msg6 = NULL;
    
    msg7 = NULL;
    
    msg8 = NULL;
    
    msg9 = NULL;
    
    msg10 = NULL;

    msg11 = NULL;

    lvlwheeltrails = 0.0;

    anim_steering_wheel = 0.0;

    anim_custom_1 = 0.0;

    anim_custom_2 = 0.0;

    anim_custom_3 = 0.0;

    anim_right_front_wheel_rotation = 0;

    anim_left_front_wheel_rotation = 0;

    anim_right_rear_wheel_rotation = 0.0;

    anim_left_rear_wheel_rotation = 0.0;

    anim_right_front_wheel_steer = 0.0;

    anim_left_front_wheel_steer = 0.0;

    anim_right_front_wheel_travel = 0.0;

    anim_left_front_wheel_travel = 0.0;

    anim_right_rear_wheel_travel = 0.0;

    anim_left_rear_wheel_travel = 0.0;

    th_dummy = NULL;

    thg_dummy = NULL;

    R = 0.0;

    main_fuel_tank_max = 0.0;

    x = 0.0;

    z = 0.0;

    FR_status = '\0';

    FL_status = '\0';

    RR_status = '\0';

    RL_status = '\0';

    dxFR = 0.0;

    dxFL = 0.0;

    dxRR = 0.0;

    dxRL = 0.0;

    dzFR = 0.0;

    dzFL = 0.0;

    dzRR = 0.0;

    dzRL = 0.0;

    uimesh_UCFO = 0;

    wheel_base = 0.0;

    wheel_track = 0.0;

    rear_right_wheel_contact = _V(0, 0, 0);
    
    rear_left_wheel_contact = _V(0, 0, 0);
    
    front_right_wheel_contact = _V(0, 0, 0);
    
    front_left_wheel_contact = _V(0, 0, 0);
    
    wheel_base = front_right_wheel_contact.z - rear_right_wheel_contact.x;

    wheel_track = front_right_wheel_contact.x - front_left_wheel_contact.x;

    front_stiffness = 0.0;

    front_damping = 0.0;

    rear_stiffness = 0.0;

    rear_damping = 0.0;

    body_stiffness = 0.0;

    body_damping = 0.0;

    drive_status = 'F';

    empty_mass = 0.0;

    max_weight_front = 0.0;

    max_weight = 0.0;

    max_weight_vector = _V(0, 0, 0);

    max_weight_rear = 0.0;

    MeshName[0] = '\0';

    size = 0.0;
    
    steering_angle = 0.0;

    turn_radius = 0.0;

    angle_left = 0.0;

    angle_right = 0.0;

    right_rear_wheel_rotation = 0.0;
    
    right_front_wheel_rotation = 0.0;
    
    left_rear_wheel_rotation = 0.0;
    
    left_front_wheel_rotation = 0.0;

    front_right_skid_force_axis = _V(0, 0, 0);
    
    front_left_skid_force_axis = _V(0, 0, 0);
    
    rear_right_skid_force_axis = _V(0, 0, 0);
    
    rear_left_skid_force_axis = _V(0, 0, 0);

    front_right_wheel_force = 0.0;
    
    front_left_wheel_force = 0.0;
    
    rear_right_wheel_force = 0.0;
    
    rear_left_wheel_force = 0.0;

    front_right_skid_force = _V(0, 0, 0);
    
    front_left_skid_force = _V(0, 0, 0);
    
    rear_right_skid_force = _V(0, 0, 0);
    
    rear_left_skid_force = _V(0, 0, 0);

    velFR = _V(0, 0, 0);
    
    velFL = _V(0, 0, 0);
    
    velRR = _V(0, 0, 0);
    
    velRL = _V(0, 0, 0);

    pitch = 0.0;
    
    yaw = 0.0;
    
    bank = 0.0;

    front_right_turning_force_axis = _V(0, 0, 0);
    
    front_left_turning_force_axis = _V(0, 0, 0);
    
    rear_right_turning_force_axis = _V(0, 0, 0);
    
    rear_left_turning_force_axis = _V(0, 0, 0);

    front_right_wheel_contact_local = _V(0, 0, 0);
    
    front_left_wheel_contact_local = _V(0, 0, 0);
    
    rear_right_wheel_contact_local = _V(0, 0, 0);
    
    rear_left_wheel_contact_local = _V(0, 0, 0);

    mass = 0.0;

    omega = _V(0, 0, 0);

    front_left_tilt_angle = 0.0;

    front_right_tilt_angle = 0.0;
    
    rear_right_tilt_angle = 0.0;
    
    rear_left_tilt_angle = 0.0;

    front_right_displacement = 0.0;
    
    front_left_displacement = 0.0;
    
    rear_right_displacement = 0.0;
    
    rear_left_displacement = 0.0;

    front_right_axle_axis = _V(0, 0, 0);

    front_left_axle_axis = _V(0, 0, 0);

    rear_left_axle_axis = _V(0, 0, 0);

    rear_right_axle_axis = _V(0, 0, 0);

    left_headlight_beacon_spec = {
        0,
        nullptr,
        nullptr,
        0,
        0,
        0,
        0,
        false
    };

    right_headlight_beacon_spec = {
        0,
        nullptr,
        nullptr,
        0,
        0,
        0,
        0,
        false
    };

    left_tail_light_spec = {
        0,
        nullptr,
        nullptr,
        0,
        0,
        0,
        0,
        false
    };

    right_tail_light_spec = {
        0,
        nullptr,
        nullptr,
        0,
        0,
        0,
        0,
        false
    };

    left_backup_light_spec = {
        0,
        nullptr,
        nullptr,
        0,
        0,
        0,
        0,
        false
    };

    right_backup_light_spec = {
        0,
        nullptr,
        nullptr,
        0,
        0,
        0,
        0,
        false
    };

    left_headlight = nullptr;

    right_headlight = nullptr;

    left_tail_light_point = nullptr;

    right_tail_light_point = nullptr;

    left_backup_light_point = nullptr;

    right_backup_light_point = nullptr;

    headlight_status = '\0';

    Fuel = nullptr;

    flw_parent1 = nullptr;
    
    flw_parent2 = nullptr;
    
    frw_parent1 = nullptr;
    
    frw_parent2 = nullptr;
    
    rrw_parent1 = nullptr;
    
    rlw_parent1 = nullptr;

}
 
Yes, here is my constructor:

C++:
//Constructor
UCFO::UCFO(OBJHANDLE hVessel, int flightmodel) :
VESSEL4(hVessel, flightmodel){

    mhUCFO = NULL;

    vhUCFO = NULL;

    mhcockpitUCFO = NULL;

    front_left_wheel_id = 0;

    front_right_wheel_id = 0;

    rear_right_wheel_id = 0;

    rear_left_wheel_id = 0;

    steering_wheel_id = 0;

    msg1 = NULL;

    msg2 = NULL;
 
    msg3 = NULL;
 
    msg4 = NULL;
 
    msg5 = NULL;
 
    msg6 = NULL;
 
    msg7 = NULL;
 
    msg8 = NULL;
 
    msg9 = NULL;
 
    msg10 = NULL;

    msg11 = NULL;

    lvlwheeltrails = 0.0;

    anim_steering_wheel = 0.0;

    anim_custom_1 = 0.0;

    anim_custom_2 = 0.0;

    anim_custom_3 = 0.0;

    anim_right_front_wheel_rotation = 0;

    anim_left_front_wheel_rotation = 0;

    anim_right_rear_wheel_rotation = 0.0;

    anim_left_rear_wheel_rotation = 0.0;

    anim_right_front_wheel_steer = 0.0;

    anim_left_front_wheel_steer = 0.0;

    anim_right_front_wheel_travel = 0.0;

    anim_left_front_wheel_travel = 0.0;

    anim_right_rear_wheel_travel = 0.0;

    anim_left_rear_wheel_travel = 0.0;

    th_dummy = NULL;

    thg_dummy = NULL;

    R = 0.0;

    main_fuel_tank_max = 0.0;

    x = 0.0;

    z = 0.0;

    FR_status = '\0';

    FL_status = '\0';

    RR_status = '\0';

    RL_status = '\0';

    dxFR = 0.0;

    dxFL = 0.0;

    dxRR = 0.0;

    dxRL = 0.0;

    dzFR = 0.0;

    dzFL = 0.0;

    dzRR = 0.0;

    dzRL = 0.0;

    uimesh_UCFO = 0;

    wheel_base = 0.0;

    wheel_track = 0.0;

    rear_right_wheel_contact = _V(0, 0, 0);
 
    rear_left_wheel_contact = _V(0, 0, 0);
 
    front_right_wheel_contact = _V(0, 0, 0);
 
    front_left_wheel_contact = _V(0, 0, 0);
 
    wheel_base = front_right_wheel_contact.z - rear_right_wheel_contact.x;

    wheel_track = front_right_wheel_contact.x - front_left_wheel_contact.x;

    front_stiffness = 0.0;

    front_damping = 0.0;

    rear_stiffness = 0.0;

    rear_damping = 0.0;

    body_stiffness = 0.0;

    body_damping = 0.0;

    drive_status = 'F';

    empty_mass = 0.0;

    max_weight_front = 0.0;

    max_weight = 0.0;

    max_weight_vector = _V(0, 0, 0);

    max_weight_rear = 0.0;

    MeshName[0] = '\0';

    size = 0.0;
 
    steering_angle = 0.0;

    turn_radius = 0.0;

    angle_left = 0.0;

    angle_right = 0.0;

    right_rear_wheel_rotation = 0.0;
 
    right_front_wheel_rotation = 0.0;
 
    left_rear_wheel_rotation = 0.0;
 
    left_front_wheel_rotation = 0.0;

    front_right_skid_force_axis = _V(0, 0, 0);
 
    front_left_skid_force_axis = _V(0, 0, 0);
 
    rear_right_skid_force_axis = _V(0, 0, 0);
 
    rear_left_skid_force_axis = _V(0, 0, 0);

    front_right_wheel_force = 0.0;
 
    front_left_wheel_force = 0.0;
 
    rear_right_wheel_force = 0.0;
 
    rear_left_wheel_force = 0.0;

    front_right_skid_force = _V(0, 0, 0);
 
    front_left_skid_force = _V(0, 0, 0);
 
    rear_right_skid_force = _V(0, 0, 0);
 
    rear_left_skid_force = _V(0, 0, 0);

    velFR = _V(0, 0, 0);
 
    velFL = _V(0, 0, 0);
 
    velRR = _V(0, 0, 0);
 
    velRL = _V(0, 0, 0);

    pitch = 0.0;
 
    yaw = 0.0;
 
    bank = 0.0;

    front_right_turning_force_axis = _V(0, 0, 0);
 
    front_left_turning_force_axis = _V(0, 0, 0);
 
    rear_right_turning_force_axis = _V(0, 0, 0);
 
    rear_left_turning_force_axis = _V(0, 0, 0);

    front_right_wheel_contact_local = _V(0, 0, 0);
 
    front_left_wheel_contact_local = _V(0, 0, 0);
 
    rear_right_wheel_contact_local = _V(0, 0, 0);
 
    rear_left_wheel_contact_local = _V(0, 0, 0);

    mass = 0.0;

    omega = _V(0, 0, 0);

    front_left_tilt_angle = 0.0;

    front_right_tilt_angle = 0.0;
 
    rear_right_tilt_angle = 0.0;
 
    rear_left_tilt_angle = 0.0;

    front_right_displacement = 0.0;
 
    front_left_displacement = 0.0;
 
    rear_right_displacement = 0.0;
 
    rear_left_displacement = 0.0;

    front_right_axle_axis = _V(0, 0, 0);

    front_left_axle_axis = _V(0, 0, 0);

    rear_left_axle_axis = _V(0, 0, 0);

    rear_right_axle_axis = _V(0, 0, 0);

    left_headlight_beacon_spec = {
        0,
        nullptr,
        nullptr,
        0,
        0,
        0,
        0,
        false
    };

    right_headlight_beacon_spec = {
        0,
        nullptr,
        nullptr,
        0,
        0,
        0,
        0,
        false
    };

    left_tail_light_spec = {
        0,
        nullptr,
        nullptr,
        0,
        0,
        0,
        0,
        false
    };

    right_tail_light_spec = {
        0,
        nullptr,
        nullptr,
        0,
        0,
        0,
        0,
        false
    };

    left_backup_light_spec = {
        0,
        nullptr,
        nullptr,
        0,
        0,
        0,
        0,
        false
    };

    right_backup_light_spec = {
        0,
        nullptr,
        nullptr,
        0,
        0,
        0,
        0,
        false
    };

    left_headlight = nullptr;

    right_headlight = nullptr;

    left_tail_light_point = nullptr;

    right_tail_light_point = nullptr;

    left_backup_light_point = nullptr;

    right_backup_light_point = nullptr;

    headlight_status = '\0';

    Fuel = nullptr;

    flw_parent1 = nullptr;
 
    flw_parent2 = nullptr;
 
    frw_parent1 = nullptr;
 
    frw_parent2 = nullptr;
 
    rrw_parent1 = nullptr;
 
    rlw_parent1 = nullptr;

}
I haven't coded C++ in a while, but I believe you need to also specify the data type? I see that the first two animation states are 0, where the others are 0.0. The animations may be expecting a float and are getting an int instead?

Lua is rather sloppy about data typing, but C++ is rather ruthless about it.

 
I haven't coded C++ in a while, but I believe you need to also specify the data type? I see that the first two animation states are 0, where the others are 0.0. The animations may be expecting a float and are getting an int instead?

Lua is rather sloppy about data typing, but C++ is rather ruthless about it.

C++:
/////////////////////////////////////////////////////
//          Copyright (c)2024 Matías Saibene       //
//ORBITER MODULE: UNIVERSAL CARS FOR ORBITER (UCFO)//
//          Licenced under the MIT Licence         //
//              main.h  Main header file           //
/////////////////////////////////////////////////////
#pragma once

#ifndef __MAIN_H
#define __MAIN_H

#define STRICT 1

#include <cmath>
#include <cstddef>
#include <exception>
#include <sys/types.h>
#include <cstring>
#include <cstdio>
#include <cstdint>
#include <limits>

#include "HEADERS//Orbitersdk.h"
#include "HEADERS//OrbiterAPI.h"
#include "HEADERS//ModuleAPI.h"
#include "HEADERS//VesselAPI.h"
#include "HEADERS//XRSound.h"
#include "HEADERS//GraphicsAPI.h"

const double UCFO_ISP = 2e4;

const double UCFO_FUEL_MASS = 50; //Fuel mass in kg.

const VECTOR3 ENGINE_LOCATION = {0, 0, 0};

const VECTOR3 FORWARD_DIRECTION = {0, 0, 1};

const VECTOR3 BACKWARD_DIRECTION = {0, 0, -1};

static const int ntdvtx = 12;

class UCFO : public VESSEL4{

    public:

        UCFO(OBJHANDLE hVessel, int flightmodel);

        virtual ~UCFO();

        void TerminateAtError(const char *error, const char * className, const char *type);

        void DefineAnimations();
        void clbkSetClassCaps(FILEHANDLE cfg) override;
        void clbkLoadStateEx(FILEHANDLE scn, void *vs) override;
        void clbkPostCreation() override;
        void clbkPreStep(double simt, double simdt, double mjd) override;
        void clbkPostStep(double simt, double simdt, double mjd) override;
        int clbkConsumeBufferedKey(int key, bool down, char *kstate) override;
        int clbkConsumeDirectKey(char *kstate) override;

        VECTOR3 RotatePitch(VECTOR3, double);
        VECTOR3 RotateYaw(VECTOR3, double);
        VECTOR3 RotateBank(VECTOR3, double);
        VECTOR3 Rotate(VECTOR3, double, double, double);
        void NormalForce(double pitch, double yaw, double bank);
        void WheelAxis();
        void WheelVelocity(VECTOR3, VECTOR3);
        void DynamicFriction();
        void StaticFriction();
        void StickOrSkid();
        void Caster();
        void Ackermann();
        void EnginePower();
        void Brakes();
        void SetContactTouchdownPoints();
        
        
        void SetAnnotationMessages();
        void MakeAnnotationFormat();

        void AnimRightFrontWheel();
        void AnimLeftFrontWheel();
        void AnimRightRearWheel();
        void AnimLeftRearWheel();

        double UpdateLvlWheelsTrails();

        void MakeLightHeadlights();
        void MakeLightTaillights();
        void MakeLightBackuplights();
        void SetLightHeadlights();
        void SetLightBrakelights();
        void SetLightBackuplights();

        VISHANDLE vhUCFO;
        MESHHANDLE mhUCFO, mhcockpitUCFO;
        unsigned int uimesh_UCFO;
        unsigned int uimesh_Cockpit = 1;

    private:

        char MeshName[256];
        double size;
        double empty_mass;

        int front_left_wheel_id;
        int front_right_wheel_id;
        int rear_right_wheel_id;
        int rear_left_wheel_id;
        int steering_wheel_id;
        VECTOR3 front_left_wheel_pos;
        VECTOR3 front_right_wheel_pos;
        VECTOR3 rear_left_wheel_pos;
        VECTOR3 rear_right_wheel_pos;
        VECTOR3 left_headlight_pos;
        VECTOR3 right_headlight_pos;
        VECTOR3 left_tail_light_pos;
        VECTOR3 right_tail_light_pos;
        VECTOR3 left_backup_pos;
        VECTOR3 right_backup_pos;
        VECTOR3 camera_pos;
        VECTOR3 TDP1;
        VECTOR3 TDP2;
        VECTOR3 TDP3;
        VECTOR3 TDP4;
        VECTOR3 TDP5;
        VECTOR3 TDP6;
        VECTOR3 TDP7;
        VECTOR3 TDP8;

        NOTEHANDLE msg1, msg2, msg3, msg4, msg5, msg6, msg7, msg8, msg9, msg10, msg11;
        
        const char *cockpit_meshname = NULL;

        double lvlwheeltrails;

        double anim_delay = 0.5;

        unsigned int anim_steering_wheel;
        

        unsigned int anim_custom_1;
        unsigned int anim_custom_2;
        unsigned int anim_custom_3;

        unsigned int anim_right_front_wheel_rotation, anim_left_front_wheel_rotation, anim_right_rear_wheel_rotation, anim_left_rear_wheel_rotation;

        double right_rear_wheel_rotation, right_front_wheel_rotation, left_rear_wheel_rotation, left_front_wheel_rotation;

        unsigned int anim_right_front_wheel_steer, anim_left_front_wheel_steer;
        unsigned int anim_right_front_wheel_travel, anim_left_front_wheel_travel, anim_right_rear_wheel_travel,
        anim_left_rear_wheel_travel;

        THRUSTER_HANDLE th_dummy;
        THGROUP_HANDLE thg_dummy;
        BEACONLIGHTSPEC left_headlight_beacon_spec, right_headlight_beacon_spec, right_tail_light_spec, left_tail_light_spec, left_backup_light_spec, right_backup_light_spec;
        ANIMATIONCOMPONENT_HANDLE flw_parent1, flw_parent2, frw_parent1, frw_parent2, rrw_parent1, rlw_parent1;
        MGROUP_ROTATE *left_front_wheel_steer, *left_front_wheel_rotate, *right_front_wheel_steer, *right_front_wheel_rotate,*right_rear_wheel_rotate, *left_rear_wheel_rotate;
        MGROUP_TRANSLATE *left_front_wheel_travel, *right_front_wheel_travel, *right_rear_wheel_travel, *left_rear_wheel_travel;
        //SURFHANDLE skin[1];
        //char skinpath[256];
        LightEmitter *left_headlight, *right_headlight, *left_tail_light_point, *right_tail_light_point, *left_backup_light_point, *right_backup_light_point;
        COLOUR4 col_white_d = {0.9,0.8,1,0};
        COLOUR4 col_white_s = {1.9,0.8,1,0};
        COLOUR4 col_white_a = {0,0,0,0};
        COLOUR4 col_red_d = {1, 0, 0, 1};
        COLOUR4 col_red_s = {1, 0, 0, 1};
        COLOUR4 col_red_a = {1, 0, 0, 1};
        VECTOR3 col_white = {1, 1, 1};
        VECTOR3 col_red = {1.0, 0.0, 0.0};

        double steering_angle;
        double R;
        double wheel_base;
        double angle_right;
        double angle_left;
        double wheel_track;
        double turn_radius;
        char brake_status = 'F';
        VECTOR3 vel;
        double mu_dyn = 0.7;
        double mu_sta = 1.0; //static friction coefficient (rubber on asphalt)
        double max_weight;
        double wheel_radius = 0.322;
        double main_fuel_tank_max;
        char drive_status;
        double pitch, yaw, bank;
        VECTOR3 omega;
        double x, z;
        VECTOR3 y;
        VECTOR3 angvel;
        int mass;
        PROPELLANT_HANDLE Fuel;
        double max_weight_rear, max_weight_front;
        VECTOR3 rear_right_wheel_contact, rear_left_wheel_contact, front_right_wheel_contact, front_left_wheel_contact;
        VECTOR3 max_weight_vector;
        double front_stiffness, rear_stiffness, body_stiffness;
        double front_damping, rear_damping, body_damping;
        double travel = 0.06;
        double front_left_tilt_angle, front_right_tilt_angle, rear_right_tilt_angle, rear_left_tilt_angle;
        double front_right_displacement, front_left_displacement, rear_right_displacement, rear_left_displacement;
        double front_right_wheel_force, front_left_wheel_force, rear_right_wheel_force, rear_left_wheel_force;
        VECTOR3 front_right_axle_axis, front_left_axle_axis, rear_right_axle_axis, rear_left_axle_axis;
        VECTOR3 velFR, velFL, velRR, velRL;
        VECTOR3 front_right_skid_force, front_left_skid_force, rear_right_skid_force, rear_left_skid_force;
        VECTOR3 front_right_skid_force_axis, front_left_skid_force_axis, rear_right_skid_force_axis, rear_left_skid_force_axis;
        VECTOR3 front_right_turning_force, front_left_turning_force, rear_right_turning_force, rear_left_turning_force;
        VECTOR3 front_right_turning_force_axis, front_left_turning_force_axis, rear_right_turning_force_axis, rear_left_turning_force_axis;
        VECTOR3 front_right_wheel_contact_local, front_left_wheel_contact_local, rear_right_wheel_contact_local, rear_left_wheel_contact_local;
        char FR_status, FL_status, RR_status, RL_status;
        char headlight_status;
        VECTOR3 front_right_wheel_axle, front_left_wheel_axle, rear_right_wheel_axle, rear_left_wheel_axle;

        //Displacements for lateral static force model

        double dxFR;
        double dxFL;
        double dxRR;
        double dxRL;

        double dzFR;
        double dzFL;
        double dzRR;
        double dzRL;

};

#endif //!__MAIN_H
 
Where are your MGROUP_TRANSFORMs allocated? heap or stack?
I'm using new
so its heap.

C++:
void UCFO::DefineAnimations() {
    unsigned int mshc = GetMeshCount();

    // Grupos de las ruedas
    unsigned int FrontLeftWheelGrp[1] = {static_cast<unsigned int>(front_left_wheel_id)};
    unsigned int FrontRightWheelGrp[1] = {static_cast<unsigned int>(front_right_wheel_id)};
    unsigned int RearRightWheelGrp[1] = {static_cast<unsigned int>(rear_right_wheel_id)};
    unsigned int RearLeftWheelGrp[1] = {static_cast<unsigned int>(rear_left_wheel_id)};

    // Animación: Rueda delantera izquierda
    left_front_wheel_steer = new MGROUP_ROTATE(
        mshc,
        FrontLeftWheelGrp,
        1,
        front_left_wheel_axle,
        _V(0, 1, 0),
        (float)(45 * RAD));
        
    anim_left_front_wheel_steer = CreateAnimation(0.5);

    flw_parent1 = AddAnimationComponent(anim_left_front_wheel_steer, 0, 1, left_front_wheel_steer);

    left_front_wheel_travel = new MGROUP_TRANSLATE(
        mshc,
        FrontLeftWheelGrp,
        1,
        _V(0, 2.0 * travel, 0));


    
    anim_left_front_wheel_travel = CreateAnimation(0.5);

    flw_parent2 = AddAnimationComponent(anim_left_front_wheel_travel, 0, 1, left_front_wheel_travel, flw_parent1);

    left_front_wheel_rotate = new MGROUP_ROTATE(
        mshc,
        FrontLeftWheelGrp,
        1,
        front_left_wheel_axle,
        _V(1, 0, 0),
        (float)(360 * RAD));
        
    anim_left_front_wheel_rotation = CreateAnimation(0.5);

    AddAnimationComponent(anim_left_front_wheel_rotation, 0, 1, left_front_wheel_rotate, flw_parent2);

    // Animación: Rueda delantera derecha
    right_front_wheel_steer = new MGROUP_ROTATE(
        mshc,
        FrontRightWheelGrp,
        1,
        front_right_wheel_axle,
        _V(0, 1, 0), (float)(45 * RAD));
    anim_right_front_wheel_steer = CreateAnimation(0.5);
    frw_parent1 = AddAnimationComponent(anim_right_front_wheel_steer, 0, 1, right_front_wheel_steer);

    right_front_wheel_travel = new MGROUP_TRANSLATE(
        mshc,
        FrontRightWheelGrp,
        1,
        _V(0, 2.0 * travel, 0));

    anim_right_front_wheel_travel = CreateAnimation(0.5);

    frw_parent2 = AddAnimationComponent(anim_right_front_wheel_travel, 0, 1, right_front_wheel_travel, frw_parent1);

    right_front_wheel_rotate = new MGROUP_ROTATE(
        mshc,
        FrontRightWheelGrp,
        1,
        front_right_wheel_axle,
        _V(1, 0, 0), (float)(360 * RAD));

    anim_right_front_wheel_rotation = CreateAnimation(0.5);

    AddAnimationComponent(anim_right_front_wheel_rotation, 0, 1, right_front_wheel_rotate, frw_parent2);

    // Animación: Rueda trasera derecha
    right_rear_wheel_travel = new MGROUP_TRANSLATE(
        mshc,
        RearRightWheelGrp,
        1,
        _V(0, 2.0 * travel, 0));

    anim_right_rear_wheel_travel = CreateAnimation(0.5);

    rrw_parent1 = AddAnimationComponent(anim_right_rear_wheel_travel, 0, 1, right_rear_wheel_travel);

    right_rear_wheel_rotate = new MGROUP_ROTATE(
        mshc,
        RearRightWheelGrp,
        1,
        rear_right_wheel_axle,
        _V(1, 0, 0), (float)(360 * RAD));

    anim_right_rear_wheel_rotation = CreateAnimation(0.5);

    AddAnimationComponent(anim_right_rear_wheel_rotation, 0, 1, right_rear_wheel_rotate, rrw_parent1);

    // Animación: Rueda trasera izquierda
    left_rear_wheel_travel = new MGROUP_TRANSLATE(
        mshc,
        RearLeftWheelGrp,
        1,
        _V(0, 2.0 * travel, 0));

    anim_left_rear_wheel_travel = CreateAnimation(0.5);

    rlw_parent1 = AddAnimationComponent(anim_left_rear_wheel_travel, 0, 1, left_rear_wheel_travel);

    left_rear_wheel_rotate = new MGROUP_ROTATE(
        mshc,
        RearLeftWheelGrp,
        1,
        rear_left_wheel_axle,
        _V(1, 0, 0), (float)(360 * RAD));

    anim_left_rear_wheel_rotation = CreateAnimation(0.5);

    AddAnimationComponent(anim_left_rear_wheel_rotation, 0, 1, left_rear_wheel_rotate, rlw_parent1);

}
 
I've noticed that when I try to turn (by pressing 1 or 3 on the numpad) the vehicle flies off the ground (this happens in Windows and WINE). And once this happens, the turning angle starts to be displayed, as if when I was on Earth I couldn't turn the wheels. Although I can't see the vehicle, I can see the messages on the screen.

I'm attaching the UCFO modules, so you can try them out and give me some clues.

By the way, the GitHub repository already has the updated code: https://github.com/MatiasSaibene/UniversalCarsForOrbiter
 

Attachments

I'm using new
so its heap.

C++:
void UCFO::DefineAnimations() {
    unsigned int mshc = GetMeshCount();

    // Grupos de las ruedas
    unsigned int FrontLeftWheelGrp[1] = {static_cast<unsigned int>(front_left_wheel_id)};
    unsigned int FrontRightWheelGrp[1] = {static_cast<unsigned int>(front_right_wheel_id)};
    unsigned int RearRightWheelGrp[1] = {static_cast<unsigned int>(rear_right_wheel_id)};
    unsigned int RearLeftWheelGrp[1] = {static_cast<unsigned int>(rear_left_wheel_id)};

    // Animación: Rueda delantera izquierda
    left_front_wheel_steer = new MGROUP_ROTATE(
        mshc,
        FrontLeftWheelGrp,
        1,
        front_left_wheel_axle,
        _V(0, 1, 0),
        (float)(45 * RAD));
       
    anim_left_front_wheel_steer = CreateAnimation(0.5);

    flw_parent1 = AddAnimationComponent(anim_left_front_wheel_steer, 0, 1, left_front_wheel_steer);

    left_front_wheel_travel = new MGROUP_TRANSLATE(
        mshc,
        FrontLeftWheelGrp,
        1,
        _V(0, 2.0 * travel, 0));


   
    anim_left_front_wheel_travel = CreateAnimation(0.5);

    flw_parent2 = AddAnimationComponent(anim_left_front_wheel_travel, 0, 1, left_front_wheel_travel, flw_parent1);

    left_front_wheel_rotate = new MGROUP_ROTATE(
        mshc,
        FrontLeftWheelGrp,
        1,
        front_left_wheel_axle,
        _V(1, 0, 0),
        (float)(360 * RAD));
       
    anim_left_front_wheel_rotation = CreateAnimation(0.5);

    AddAnimationComponent(anim_left_front_wheel_rotation, 0, 1, left_front_wheel_rotate, flw_parent2);

    // Animación: Rueda delantera derecha
    right_front_wheel_steer = new MGROUP_ROTATE(
        mshc,
        FrontRightWheelGrp,
        1,
        front_right_wheel_axle,
        _V(0, 1, 0), (float)(45 * RAD));
    anim_right_front_wheel_steer = CreateAnimation(0.5);
    frw_parent1 = AddAnimationComponent(anim_right_front_wheel_steer, 0, 1, right_front_wheel_steer);

    right_front_wheel_travel = new MGROUP_TRANSLATE(
        mshc,
        FrontRightWheelGrp,
        1,
        _V(0, 2.0 * travel, 0));

    anim_right_front_wheel_travel = CreateAnimation(0.5);

    frw_parent2 = AddAnimationComponent(anim_right_front_wheel_travel, 0, 1, right_front_wheel_travel, frw_parent1);

    right_front_wheel_rotate = new MGROUP_ROTATE(
        mshc,
        FrontRightWheelGrp,
        1,
        front_right_wheel_axle,
        _V(1, 0, 0), (float)(360 * RAD));

    anim_right_front_wheel_rotation = CreateAnimation(0.5);

    AddAnimationComponent(anim_right_front_wheel_rotation, 0, 1, right_front_wheel_rotate, frw_parent2);

    // Animación: Rueda trasera derecha
    right_rear_wheel_travel = new MGROUP_TRANSLATE(
        mshc,
        RearRightWheelGrp,
        1,
        _V(0, 2.0 * travel, 0));

    anim_right_rear_wheel_travel = CreateAnimation(0.5);

    rrw_parent1 = AddAnimationComponent(anim_right_rear_wheel_travel, 0, 1, right_rear_wheel_travel);

    right_rear_wheel_rotate = new MGROUP_ROTATE(
        mshc,
        RearRightWheelGrp,
        1,
        rear_right_wheel_axle,
        _V(1, 0, 0), (float)(360 * RAD));

    anim_right_rear_wheel_rotation = CreateAnimation(0.5);

    AddAnimationComponent(anim_right_rear_wheel_rotation, 0, 1, right_rear_wheel_rotate, rrw_parent1);

    // Animación: Rueda trasera izquierda
    left_rear_wheel_travel = new MGROUP_TRANSLATE(
        mshc,
        RearLeftWheelGrp,
        1,
        _V(0, 2.0 * travel, 0));

    anim_left_rear_wheel_travel = CreateAnimation(0.5);

    rlw_parent1 = AddAnimationComponent(anim_left_rear_wheel_travel, 0, 1, left_rear_wheel_travel);

    left_rear_wheel_rotate = new MGROUP_ROTATE(
        mshc,
        RearLeftWheelGrp,
        1,
        rear_left_wheel_axle,
        _V(1, 0, 0), (float)(360 * RAD));

    anim_left_rear_wheel_rotation = CreateAnimation(0.5);

    AddAnimationComponent(anim_left_rear_wheel_rotation, 0, 1, left_rear_wheel_rotate, rlw_parent1);

}
I'm not sure it's correct to use GetMeshCount() in your MGROUPs since it'll return one over the last valid index.
 
I'm not sure it's correct to use GetMeshCount() in your MGROUPs since it'll return one over the last valid index.
Thanks, I've fixed it:
C++:
void UCFO::DefineAnimations() {

    //unsigned int mshc = GetMeshCount();

    //Wheels groups
    unsigned int FrontLeftWheelGrp[1] = {static_cast<unsigned int>(front_left_wheel_id)};
    unsigned int FrontRightWheelGrp[1] = {static_cast<unsigned int>(front_right_wheel_id)};
    unsigned int RearRightWheelGrp[1] = {static_cast<unsigned int>(rear_right_wheel_id)};
    unsigned int RearLeftWheelGrp[1] = {static_cast<unsigned int>(rear_left_wheel_id)};


    left_front_wheel_steer = new MGROUP_ROTATE(
        0,
        FrontLeftWheelGrp,
        1,
        front_left_wheel_axle,
        _V(0, 1, 0),
        (float)(45 * RAD));
       
    anim_left_front_wheel_steer = CreateAnimation(0.5);
However, the errors remain. I think the best thing would be to adapt the GeneralVehicle code for turning and touchdown points. I think...
 
I don't know exactly what you are seeing, but the wheel animations are complicated as the wheel turns on its axis, rotates about the vertical axis for steering, and translates vertically for strut compliance. All of these transformations are done concurrently. I recall that there was a problem where a mesh element was needed as a axle rotation reference for the two nested rotations. I basically just grabbed a triangle from the wheel mesh group and made it into a separate mesh group to enable this, then set it to be invisible.

I know you have been working with your Citroën mesh, but you might want to take my VWThing mesh and get your code working with that. You can then compare your code performance to my script.
 
I don't know exactly what you are seeing, but the wheel animations are complicated as the wheel turns on its axis, rotates about the vertical axis for steering, and translates vertically for strut compliance. All of these transformations are done concurrently. I recall that there was a problem where a mesh element was needed as a axle rotation reference for the two nested rotations. I basically just grabbed a triangle from the wheel mesh group and made it into a separate mesh group to enable this, then set it to be invisible.

I know you have been working with your Citroën mesh, but you might want to take my VWThing mesh and get your code working with that. You can then compare your code performance to my script.
I'll try it and let you know.
 
What does gdb make out of this?
Code:
Starting program: /home/matias/orbiter_test/Orbiter/Orbiter
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
[New Thread 0x7fffe99ff6c0 (LWP 12231)]
[New Thread 0x7fffe91fe6c0 (LWP 12232)]
[New Thread 0x7fffe1fdc6c0 (LWP 12234)]
[Thread 0x7fffe1fdc6c0 (LWP 12234) exited]
[New Thread 0x7fffe17db6c0 (LWP 12235)]
[Thread 0x7fffe17db6c0 (LWP 12235) exited]

Thread 1 "Orbiter" received signal SIGSEGV, Segmentation fault.
0x000055555585dd79 in ZTreeMgr::Idx(int, int, int) ()
#0  0x000055555585dd79 in ZTreeMgr::Idx(int, int, int) ()
#1  0x000055555585dd3b in ZTreeMgr::Idx(int, int, int) ()
#2  0x000055555585dd3b in ZTreeMgr::Idx(int, int, int) ()
#3  0x000055555585dd3b in ZTreeMgr::Idx(int, int, int) ()
#4  0x000055555585dd3b in ZTreeMgr::Idx(int, int, int) ()
#5  0x000055555585dd3b in ZTreeMgr::Idx(int, int, int) ()
#6  0x000055555585dd3b in ZTreeMgr::Idx(int, int, int) ()
#7  0x000055555585dd3b in ZTreeMgr::Idx(int, int, int) ()
#8  0x000055555585dd3b in ZTreeMgr::Idx(int, int, int) ()
#9  0x000055555585dd3b in ZTreeMgr::Idx(int, int, int) ()
#10 0x000055555585dd3b in ZTreeMgr::Idx(int, int, int) ()
#11 0x0000555555716f72 in ZTreeMgr::ReadData(int, int, int, unsigned char**) ()
#12 0x0000555555713678 in ElevationManager::LoadElevationTile(int, int, int, double) const ()
#13 0x00005555557148a2 in ElevationManager::Elevation(double, double, int, std::vector<ElevationTile, std::allocator<ElevationTile> >*, Vector*, int*) const ()
#14 0x00005555557aaf8e in Vessel::AddSurfaceForces(Vector*, Vector*, StateVectors const*, double, double, bool) const ()
#15 0x00005555557969e4 in Vessel::GetIntermediateMoments(Vector&, Vector&, StateVectors const&, double, double) ()
#16 0x00005555557700ea in RigidBody::RKdrv_LinAng(double, int, int, int, double const*, double const*, double const*) ()
#17 0x000055555577059b in RigidBody::RK8_LinAng(double, int, int) ()
#18 0x000055555577e62a in RigidBody::Update(bool) ()
#19 0x00005555557accbd in Vessel::Update(bool) ()
#20 0x000055555573e8f6 in PlanetarySystem::Update(bool) ()
#21 0x0000555555728fef in Orbiter::UpdateWorld() ()
#22 0x0000555555725d11 in Orbiter::Run() ()
#23 0x000055555572255a in main ()
quit
 
I'll try it and let you know.
I'm looking through my mesh now. The issue was that all of the parent animations required a mesh group to be supplied in the spec, but because all of the transformations were performed simultaneously and not sequentially, those parent mesh groups could not be the mesh groups of the actual moving wheels. So I literally just made some dummy small triangular mesh groups and made those mesh groups invisible using FLAG 0x00000002 in the mesh file. If you search for the mesh file for FLAG you'll find these groups easily.

This was a hack to get the animations to work the way I needed them to. If anyone knows of a better and more intuitive way to get multiple rotations and translations to work with the same mesh groups without this I'd be glad to hear of them, but after a lot of investigating it seemed to be the only way at the time.
 
Looking at my code, it probably wasn't necessary to make a lot of these dummy mesh groups. Only one was needed to be supplied to the parent animations, and as far as I can tell the same one could have been used for all of them. It's literally just a placeholder to create the parent animations. That dummy meshgroup gets translated and rotated all over the place, but making it invisible fixed that incongruity.

This thread illustrates the struggles to get it to work.

 
Last edited:
Looking at my code, it probably wasn't necessary to make a lot of these dummy mesh groups. Only one was needed to be supplied to the parent animations, and as far as I can tell the same one could have been used for all of them. It's literally just a placeholder to create the parent animations. That dummy meshgroup gets translated and rotated all over the place, but making it invisible fixed that incongruity.

This thread illustrates the struggles to get it to work.

I understand what you're saying.
I've had the experience of running animations that they become distorted over time (the rudder of my Boeing 747 is an example).

I'll check out the examples of the XR5 which has wheel spin (forward and on its axles) and compression in the landing gear.
 
Back
Top