Game-Engine Vehicle Functions

class BeamNGVehicle

class BeamNGVehicle : ShapeBase
BeamNGVehicle()

Creates a new BeamNGVehicle-Object

Example:

local veh = BeamNGVehicle() -- Creates a new BeamNGVehicle-Object
local veh = scenetree.findObject(5213) -- Gets the BeamNGVehicle via its ID
-- You can get the ID by the Editor using Scene Tree
bool playerUsable

Player can enter/drive the vehicle

local veh = scenetree.findObject(15725)
-- You are getting the ID from the Editor at the Scene Tree
print(veh.playerUsable)
float camFOV

camera Field Of View

local veh = scenetree.findObject(15725)
-- You are getting the ID from the Editor at the Scene Tree
print(veh.camFOV) -- prints 50
string getPath()

Get the vehicle path

Returns:vehicle path like vehicle/pickup/

Example:

local veh = scenetree.findObject(15725)
-- You are getting the ID from the Editor at the Scene Tree
print(veh:getPath()) -- prints vehicles/pickup/
getJBeamFilename()

Get the vehicle folder

Returns:vehicle folder like pickup

Example:

local veh = scenetree.findObject(15725)
-- You are getting the ID from the Editor at the Scene Tree
print(veh:getJBeamFilename()) -- prints pickup
queueLuaCommand(string cmd)

Parameters:

  • string cmd: command to queue

Example:

local veh = scenetree.findObject(15725)
-- You are getting the ID from the Editor at the Scene Tree
print(veh:queueLuaCommand("print(\"Hello World\")")) -- prints Hello world to Console
playRPMLeds(float currentRPM, float rpmFirstLedTurnsOn, float rpmRedLine)
int getFFBID(char actionName)
sendForceFeedback(int ffid, float newtons)
createUITexture(string tagTexture, string url, int width, int height, int usageMode, int fps)

Note

to avoid for compatibility issue, you should use the htmlTexture module

destroyUITexture(string tagTexture)

destroy an initialised texture

Note

to avoid for compatibility issue, you should use the htmlTexture module

queueJSUITexture(string tagTexture, string js)

Add a javascript command to the queue of the texture

Note

to avoid for compatibility issue, you should use the htmlTexture module

bool isUITexture(string tagTexture)
Returns:true if the tag have a CefTexture
setPositionRotation(float px, float py, float pz, float rx, float ry, float rz, float rw)

Sets the Position and Rotation of the Vehicle-Object

Parameters:

  • float px: Position on X axis
  • float py: Position on Y axis
  • float pz: Position on Z axis
  • float rx: Rotation on X axis
  • float ry: Rotation on Y axis
  • float rz: Rotation on Z axis
  • float rw: Rotation on W

Rotation are Quaternion

Example:

local veh = scenetree.findObject(6976)
veh:setPositionRotation( 100, 100, 45, 0, 0, 0, 1)
-- Sets Veh to Position 100, 100, 45 and Rotation 0, 0, 0, 1
setFlexMeshDebugSelection(bool b)
setCameraPosRot(float px, float py, float pz, float rx, float ry, float rz, float rw)

Sets the Position and Rotation of the Camera

  • float px: Position on X axis
  • float py: Position on Y axis
  • float pz: Position on Z axis
  • float rx: Rotation on X axis
  • float ry: Rotation on Y axis
  • float rz: Rotation on Z axis
  • float rw: Rotation on W

Rotation are Quaternion

Example:

local veh = scenetree.findObject(6976)
veh:setCameraPosRot( 100, 100, 45, 0, 0, 0, 1)
float getViewportFillingCameraDistance()
Point3F getBBCenter()
Returns:(Point3F) The Center of BB

Example:

local veh = scenetree.findObject(6976)
print(veh:getBBCenter()) -- prints the Point (f.e. 99.9818, 96.2494, 43.0749)
Point3F getBSphereCenter()
Returns:The Point of the Center of the Sphere

Example:

local veh = scenetree.findObject(6976)
print(veh:getBSphereCenter()) -- prints the Point (f.e. 99.9818, 96.2494, 43.0749)
float getBSphereRadius()

Gets the radius of the B Sphere

Returns:(float) The radius of the Sphere

Example

local veh = scenetree.findObject(12841)
print(veh:getBSphereRadius()) -- prints f.e 2.97726
OrientedBox3F getSpawnWorldOOBB()
float getSpawnAABBRadius()

..todo:: What is AABB

Gets the Radius of the Spawn AABB

Example:

local veh = scenetree.findObject(12841)
-- You are getting the ID from the Editor at the Scene Tree
print(veh:getSpawnAABBRadius()) -- prints 2.8945922
MatrixF getRefNodeMatrix()

Gets the matrix of the reference mass point of the vehicle

Returns:(MatrixF)-Object with the Ref Nodes
local veh = scenetree.findObject(12841)
-- You are getting the ID from the Editor at the Scene Tree
print(veh:getRefNodeMatrix())

prints in console:

0.999999, -2.40651e-05, 0.0016788, -45.1894
4.79968e-05, 0.999898, -0.0142567, -282.821
-0.00167829, 0.0142567, 0.999897, 37.4986
MatrixF getLastTransform()

Example:

local veh = scenetree.findObject(6978)
-- You are getting the ID from the Editor at the Scene Tree
print(veh:getLastTransform())
MatrixF getCameraTransform()

Example:

local veh = scenetree.findObject(6978)
-- You are getting the ID from the Editor at the Scene Tree
print(veh:getCameraTransform())

prints in console

-0.999999, 0.00115207, 0.000354693, -45.1952
-0.00120543, -0.955729, -0.294246, -276.881
1.45519e-11, -0.294246, 0.95573, 39.6829
table getColorFTable()

Gets the ColorF-Objects of the Vehicle

Array-Type: index: ColorF-Object

Returns:(table) The ColorF-Values of the VehicleObject

Example:

local veh = scenetree.findObject(6978)
-- You are getting the ID from the Editor at the Scene Tree
local colorTable = veh:getColorFTable()

for i, elem in pairs(colorTable) do
    print(i..":"..tostring(elem))
end
int getNodeCount()

Gets the Count of mass points, that exist in a Vehicle

Returns:(int) The Node-Count of the Vehicle

Example

local veh = scenetree.findObject(6978)
-- You are getting the ID from the Editor at the Scene Tree
local nodeCound = veh:getNodeCount()
print(nodeCound) -- prints f.e. 660 with Pickup-Vehicle
Point3F getNodePosition(int idx)

Parameters:

  • int idx: The Node-ID, you want to get the Position of
Returns:(Point3F) The Position of the Node-Object

Example:

local veh = scenetree.findObject(6978)
-- You are getting the ID from the Editor at the Scene Tree
local nodePosition = veh:getNodePosition(100)
print(nodePosition) -- prints -0.143675, -1.52715, 0.530596
Point3F getNodeVelocity(int idx)

Parameters:

  • int idx: The Node-id you want to get the Velocity of
Returns:(Point3F) The Velocity of the mass point in the x, y and z directions

Example:

local veh = scenetree.findObject(6978)
-- You are getting the ID from the Editor at the Scene Tree
local nodeVelocity = veh:getNodeVelocity(100) -- Gets the Velocity of the Object with ID 100
print(nodeVelocity) -- prints f.e. 0.438489, -3.03891, 0.068263
Point3F getDirectionVector()

New in version 0.12.

Gets a Vector that contains the movement of the Vehicle

Returns:(Point3f) the direction vector the vehicle is pointing to

Example:

local veh = scenetree.findObject(6978)
-- You are getting the ID from the Editor at the Scene Tree
local dirVector = veh:getDirectionVector() -- Gets the Velocity of the Object with ID 100
print(dirVector) -- prints -2.08622, 3.17044, -0.0182258
Point3F getDirectionVectorUp()

New in version 0.12.

Gets a Vector that contains the movement of the vehicle to the top

Returns:(Point3F) the up vector of the vehicle

Example:

local veh = scenetree.findObject(6978)
-- You are getting the ID from the Editor at the Scene Tree
local dirVector = veh:getDirectionVector() -- Gets the Velocity of the Object with ID 100
print(dirVector) -- prints -2.08622, 3.17044, -0.0182258
int getRefNodeId()

New in version 0.13.

Gets the reference Node-ID

Returns:(int) The referenced-Node-ID

Example:

local veh = scenetree.findObject(6978)
-- You are getting the ID from the Editor at the Scene Tree
local refNode = veh:getRefNodeId() -- Gets the reference Node ID
print(refNode) -- prints f.e. 295

return the ref node id

Point3F getVelocity()

New in version 0.13.

Returns:(Point3F) The velocity of the vehicle

Example:

local veh = scenetree.findObject(6978)
-- You are getting the ID from the Editor at the Scene Tree
local vehVelocity = veh:getVelocity() -- Gets the Veh-Velocity
print(vehVelocity) -- prints f.e. 1.92176, -3.06871, -0.0110202
resetBrokenFlexMesh()
exportColladaMesh(string path)

Gets the Collada of a Vehicle and prints it to a new file

Parameters:

  • string path: The Path, where the Collada should saved in
local veh = scenetree.findObject(6978)
-- You are getting the ID from the Editor at the Scene Tree
veh:exportColladaMesh("laslo.txt") -- Writes the Collada to file "laslo.txt"--print(vehVelocity) -- prints f.e. 1.92176, -3.06871, -0.0110202
autoplace()

Refreshes the Vehicle and sets its position / rotation of respawn to the current position and rotation. It also respawns the Vehicle

Example:

local veh = scenetree.findObject(6978)
-- You are getting the ID from the Editor at the Scene Tree
veh:autoplace()
spawnObjectWithTransform(MatrixF trans)
spawnObjectWithPosRot(float px, float py, float pz, float rx, float ry, float rz, float rw)
Parameters:
  • px – Position on X axis
  • py – Position on Y axis
  • pz – Position on Z axis
  • rx – Rotation on X axis
  • ry – Rotation on Y axis
  • rz – Rotation on Z axis
  • rw – Rotation on W

Rotation are Quaternion

bool isRenderMaterialsReady()

Gets the state of the Material to be rendered.

Returns:true if the Material is ready to be rendered, false otherwise

Example:

local veh = scenetree.findObject(6978)
-- You are getting the ID from the Editor at the Scene Tree
print(veh:isRenderMaterialsReady()) -- prints true
requestReload(bool autoplace = false)
Reloads the Vehicle to the Position

Parameters:

  • bool autoplace: Should the veh be autoplaced? Standard: false

Example:

local veh = scenetree.findObject(6978)
-- You are getting the ID from the Editor at the Scene Tree
veh:requestReload()
Point3F getCornerPosition(int cornerId)

Gets the Position of the Corner with id cornerId

Parameters:

  • int cornerId: The id of the corner, you want to get
Returns:(Point3F) The position of the corner

Example:

local veh = scenetree.findObject(6978)
-- You are getting the ID from the Editor at the Scene Tree
print(veh:getCornerPosition(1))
bool engineSoundInit(int engineId, string json, int nodeId, float noloadVol, float loadVol)

Parameters:

  • int engineId: The ID of the engine
  • string json: The Json to init the Sound
  • int nodeId: The mass-Point-ID of the node, you want to set the engine sound
  • float noloadVol:
  • float loadVol:
engineSoundUpdate(int engineId, float rpm, float load, float fundamentalFrequency, float volume)
engineSoundParameter(int engineId, char name, float value)
setFlexMeshDebugMode(char modeStr)
engineSoundParameterList(int engineId, table)