createObjectGroup()
Purpose
Link a number of 3D objects together
Description
Create a parent object which can then have child objects assigned to it to act as a single object.
Syntax
handle = createObjectGroup( origin )
Arguments
handle handle of the 3D object group
origin origin vector in 3 dimensional space { x, y, z }
Example
pos1 = { 0, 0, 0 }
pos2 = { -1, 2, 0 } * 2
size1 = { 3, 1, 1 }
size2 = { 1, 3, 1 }
worldLight( { 0, 0, -3 }, white, 100 )
setCamera( { 0, 5, 20 }, { 0, 0, 0 } )
object1 = placeObject( cube, pos1, size1 )
setObjectMaterial( object1, blue, 1, 1 )
object2 = placeObject( cube, pos2, size2 )
setObjectMaterial( object2, darkred, 1, 1 )
linkedObject = createObjectGroup( pos1 )
setObjectParent( object1, linkedObject )
setObjectParent( object2, linkedObject )
linked = true
loop
clear()
c = controls(0)
if c.a and linked then
unlinkObject( object1 )
unlinkObject( object2 )
linked = false
endif
if c.b and !linked then
setObjectParent( object1, linkedObject )
setObjectParent( object2, linkedObject )
linked = true
endif
drawObjects()
if linked then
printAt( 0, 0, "linked: press A to unlink")
rotateObject( linkedObject, { 1, 1, 1 }, 0.5 )
else
printAt( 0, 0, "unlinked: press B to link")
rotateObject( object1, { 1, 1, 1 }, 0.5 )
rotateObject( object2, { 1, 1, 1 }, 0.5 )
endif
update()
repeat
Associated Commands