setObjectParent()
Purpose
Add a 3D object to an object group
Description
Sets the parent of a 3D object to be the specified object group
Syntax
setObjectParent( object, parent )
Arguments
object handle of the 3D object to be added
parent handle of the object group created with createObjectGroup
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