Start Page » DragonScript Scripting Language » Behavior Elements: Quick and Easy Development » ECBehaviorRandomizeGeometry
Behavior adding support to randomize position, rotation and scaling.
This behavior is typically used to add variation to multiple instances of the same element added to a game world by randomizing the position, rotation and scaling before creating the element.
This behavior uses BehaviorPrepareStub to apply the changes before the element is actually created. No randomizing is done if the element is created while loading a game world.
This behavior can be used only once on an element.
Element class properties have the prefix randomizeGeometry.
.
Set enable randmoize.
randomizeGeometry.randomize
or randomizeGeometry({id}).randomize
<boolean name='randomizeGeometry.randomize'>false</boolean>
Set minimum translation that can be randomly selected.
randomizeGeometry.minTranslate
or randomizeGeometry({id}).minTranslate
<vector name='randomizeGeometry.minTranslate' x='0' y='0' z='-0.2'/>
Set maximum translation that can be randomly selected.
randomizeGeometry.maxTranslate
or randomizeGeometry({id}).maxTranslate
<vector name='randomizeGeometry.maxTranslate' x='0' y='0' z='0.2'/>
Set minimum rotation in degrees that can be randomly selected.
randomizeGeometry.minRotate
or randomizeGeometry({id}).minRotate
<vector name='randomizeGeometry.minRotate' x='0' y='-45' z=''/>
Set maximum rotation in degrees that can be randomly selected.
randomizeGeometry.maxRotate
or randomizeGeometry({id}).maxRotate
<vector name='randomizeGeometry.maxRotate' x='0' y='45' z=''/>
Set minimum scaling that can be randomly selected.
randomizeGeometry.minScale
or randomizeGeometry({id}).minScale
<vector name='randomizeGeometry.minTranslate' x='0.9' y='0.9' z='0.9'/>
Set maximum scaling that can be randomly selected.
randomizeGeometry.maxScale
or randomizeGeometry({id}).maxScale
<vector name='randomizeGeometry.maxTranslate' x='1.1' y='1.1' z='1.1'/>
This behavior has no events.
This behavior requires no other behaviors.
This behavior does not support optional behaviors.
This behavior does not required element class to be persistable (setPersistable).
Since DragonScript Module Version 1.23
This example defines an element which is element with randomized geometry parameters.
class MyElement extends BehaviorElementClass public var ECBehaviorRandomizeGeometry randomizeGeometry func new() randomizeGeometry = ECBehaviorRandomizeGeometry.new(this) randomizeGeometry.getMinRotate().setVector(Vector.new(0, -45, 0)) randomizeGeometry.getMaxRotate().setVector(Vector.new(0, 45, 0)) end end
Using element class supporting adding behaviors the behavior can be added like this:
<?xml version='1.0' encoding='UTF-8'?> <elementClass name='MyClass' class='GenericBehaviorElement'> <behavior type='ECBehaviorRandomizeGeometry'> <!-- set element properties. omit property prefix if used inside behavior tag --> <vector name='.minRotate' x='0' y='-45' z='0'/> <vector name='.maxRotate' x='0' y='45' z='0'/> </behavior> </elementClass>