The 1 st Joint International Conference on Multibody System Dynamics May 25-27, 2010, Lappeenranta, Finland Efficient implementation of 3D graphics in an MBS framework Alfonso Callejo, Santiago Tapia, Javier García de Jalón INSIA - University Institute for Automobile Research (UPM - Technical University of Madrid) Carretera de Valencia, km 7, 28031 Madrid, Spain Phone: +34 913365335 Email: {a.callejo, santiago.tapia, javier.garciadejalon}@upm.es ABSTRACT This article presents a powerful implementation of an open source 3D graphics library into a mixed MATLAB/C++ MBS framework. Firstly, the authors make a summary of the framework. Its core is an efficient semi-recursive formulation which makes the most of the system topology and that is especially suitable for large and complex MBSs. It uses optimized math routines and C++ coding of the critical functions through MATLAB’s MEX-functions. Then, the main steps of the OpenSceneGraph scene creation are described, including the importation of the scenery and the CAD models and the generation of simple bodies like bars and rods. After that, the algebraic approach to manage the motion of the bodies is explained, as well as the function callbacks which apply the geometric transformations. One of the most critical parts is the bridge between the MBS model (MATLAB-based) and the 3D graphics function (C++ based). This is done by means of a MEX-function which sets up the 3D graphics viewer in a different thread, so that it does not interfere with the numerical integration, and creates a pipeline as the link between both programs. In order to assess the performance of the implementation, three MBS models are presented: a coach, a Formula SAE racing car and a semi-trailer truck. The time profiles show that despite being simpler, the MATLAB drawing functions are much slower than the realistic 3D graphics viewer. This effectiveness makes this approach suitable for real-time simulations and allows carrying out realistic visualizations of MBSs in a simple and versatile way. Keywords: multibody systems, 3D graphics viewer, MATLAB and C++, OpenSceneGraph toolkit. 1 INTRODUCTION As in other areas of Computational Mechanics, like for example in the finite element method or in computational fluid dynamics, 3D graphics are quite essential in dynamics of multibody systems (MBS), specifically to make a straightforward definition of the topology and to display the results realistically. The authors present in this paper an approach to implement a 3D graphics viewer in a MBS framework. The main objective is to be able to display the results of the numerical integration, both while the integrator is working and at the end of the integration (as a post-process). Although the general ideas are valid for any type of framework, with the only requirement of having a C++ interface, the starting point of this approach is an optimized topological semi-recursive formulation (see References [1]-[2]) implemented in a mixed MATLAB/C++ environment. The formulation carries out two velocity transformations. First the closed-loops are opened and a velocity transformation that maps relative velocities onto Cartesian velocities is introduced symbolically. Then, a second velocity transformation applied numerically on a small system of equations leads to an even smaller system of equations in the independent relative accelerations. The final set of ODEs in the independent relative coordinates is shown in Equation (1). T T i T T T T T T i d d d d d d z z z z z z RRMRRz R τ RRQ RRTMTRz RRz (1)