transition node

Summary

The transition node modifies the value of one of a node's properties over time.

For more information see the XML reference entry for transition.

Constructor

transition.new( node , what , [id] )

The node parameter specifies the node with the property to modify.

The what parameter specifies the property to modify. Currently accepted values are position, rotation, scale and color.

The parameter id is optional. If specified the node will be given this id.

Example C.66. Use of transition constructor

<scene>
	<script type="text/x-lua">
	
		myobject = scene:getById("myobject")
	
		mytransition = transition.new(myobject, "rotation")
		mytransition:setEndValues({45, 90, 240})
		mytransition:setLength(1500)
		
		scene:appendNode(mytransition)
		
	</script>
	
	<object id="myobject" .../>
	
</scene>

Functions

node:setEndValues( end_values )

Pass in a table of values representing the end-point of the transition.

Example C.67. Use of setEndValues

<scene>
	<script type="text/x-lua">
	
		myobject = scene:getById("myobject")
	
		mytransition = transition.new(myobject, "rotation")
		
		--                        roll pitch yaw
		mytransition:setEndValues({45,  90,  240})
		mytransition:setLength(1500)
		
		scene:appendNode(mytransition)
		
	</script>
	
	<object id="myobject" .../>
	
</scene>


node:setInitValues( init_values )

Pass in a table of values representing the start-point of the transition.

Example C.68. Use of setInitValues

<scene>
	<script type="text/x-lua">
	
		myobject = scene:getById("myobject")
	
		mytransition = transition.new(myobject, "rotation")
		
		--                        roll pitch yaw
		mytransition:setInitValues({0,  90,  240})
		mytransition:setEndValues({45,  90,  240})
		mytransition:setLength(1500)
		
		scene:appendNode(mytransition)
		
	</script>
	
	<object id="myobject" .../>
	
</scene>


node:setLength( time_milliseconds )

Indicates the number of milliseconds that the transition should take.

Example C.69. Use of setLength

<scene>
	<script type="text/x-lua">
	
		myobject = scene:getById("myobject")
	
		mytransition = transition.new(myobject, "rotation")
		mytransition:setEndValues({45, 90, 240})
		mytransition:setLength(1500)
		
		scene:appendNode(mytransition)
		
	</script>
	
	<object id="myobject" .../>
	
</scene>


node:setType( type )

Indicates the type of the interpolation used for the transition. Accepted values are transition.LINEAR and transition.SMOOTH.

Example C.70. Use of setType

<scene>
	<script type="text/x-lua">
	
		myobject = scene:getById("myobject")
	
		mytransition = transition.new(myobject, "rotation")
		mytransition:setType(transition.SMOOTH)
		mytransition:setEndValues({45, 90, 240})
		mytransition:setLength(1500)
		
		scene:appendNode(mytransition)
		
	</script>
	
	<object id="myobject" .../>
	
</scene>


Functions common to action nodes

node:reset()

Resets this action such that it will occur again (from the beginning).

node:setNoTimes( val )

Sets the number of times this action should occur. Pass the value -1 to repeat indefinitely.

Example C.71. Use of setNoTimes

<scene>
	<script type="text/x-lua">
		
		mytransition = scene:getById("mytransition")
		
		mytransition:setNoTimes(10)
		
	</script>
	
	<transition id="mytransition"
				object="myplane" 
				what="position" 
				start="0 0 0" end="1 1 1" 
				length="1000 />

	<object id="myplane" type="primitives://plane.aro"/>
	
</scene>


Functions common to nodes

col graphnode:getColor()

Returns a table of 4 values - red, green, blue and alpha (transparency) between 0.0 and 1.0.

Example C.72. Use of getColor

<scene>
	<script type="text/x-lua">
		
		myplane = scene:getById("myplane")
		cols = myplace:getColor()
		red = cols[1]
		green = cols[2]
		blue = cols[3]
		alpha = cols[4]
		
	</script>
	<object id="myplane" type="primitives://plane.aro" color="0.5 1 1 0.75"/>
</scene>


boolean graphnode:isVisible()

Returns true if the node is set to visible, or false otherwise.

graphnode:setColor( col )

Sets the color of the node. Pass a 4-element table with entries { red, green, blue, alpha }. Values are expressed between 0.0 and 1.0.

Example C.73. Use of setColor

<scene>
	<script type="text/x-lua">
		
		myplane = scene:getById("myplane")
		
		--         r    g   b    a
		newcol = { 0.1, 1, 0.5, 0.25 } 
		myplane:setColor(newcol)
		
	</script>
	<object id="myplane" type="primitives://plane.aro"/>
</scene>


graphnode:setVisible( true or false )

Sets the visibility of the node. Invisible nodes are not displayed and do not respond to events e.g. onhover, onclickdown etc.