**
** \legal
** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-** Copyright (c) 2007 Chris Moore
+** Copyright (c) 2007, 2008 Chris Moore
**
** This package is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License as
set_link("radius",ValueNode_Const::create(Real(1)));
set_link("seed",ValueNode_Const::create(random.get_seed()));
set_link("speed",ValueNode_Const::create(Real(1)));
- set_link("smooth",ValueNode_Const::create(int(Random::SMOOTH_CUBIC)));
+ set_link("smooth",ValueNode_Const::create(int(RandomNoise::SMOOTH_CUBIC)));
switch(get_type())
{
case ValueBase::TYPE_ANGLE:
set_link("link",ValueNode_Const::create(value.get(Angle())));
break;
+ case ValueBase::TYPE_BOOL:
+ set_link("link",ValueNode_Const::create(value.get(bool())));
+ break;
case ValueBase::TYPE_COLOR:
set_link("link",ValueNode_Const::create(value.get(Color())));
break;
ValueBase
ValueNode_Random::operator()(Time t)const
{
- typedef const Random::SmoothType Smooth;
+ typedef const RandomNoise::SmoothType Smooth;
Real radius = (*radius_)(t).get(Real());
int seed = (*seed_)(t).get(int());
return ((*link_)(t).get( Angle()) +
Angle::deg(random(Smooth(smooth), 0, 0, 0, speed) * radius));
+ case ValueBase::TYPE_BOOL:
+ return round_to_int((*link_)(t).get( bool()) +
+ random(Smooth(smooth), 0, 0, 0, speed) * radius) > 0;
+
case ValueBase::TYPE_COLOR:
return (((*link_)(t).get( Color()) +
Color(random(Smooth(smooth), 0, 0, 0, speed),
}
bool
-ValueNode_Random::set_link_vfunc(int i,ValueNode::Handle x)
+ValueNode_Random::set_link_vfunc(int i,ValueNode::Handle value)
{
assert(i>=0 && i<link_count());
switch(i)
{
- case 0:
- link_=x;
- signal_child_changed()(i);signal_value_changed()();
- return true;
- case 1:
- radius_=x;
- signal_child_changed()(i);signal_value_changed()();
- return true;
- case 2:
- seed_=x;
- signal_child_changed()(i);signal_value_changed()();
- return true;
- case 3:
- speed_=x;
- signal_child_changed()(i);signal_value_changed()();
- return true;
- case 4:
- smooth_=x;
- signal_child_changed()(i);signal_value_changed()();
- return true;
+ case 0: CHECK_TYPE_AND_SET_VALUE(link_, get_type());
+ case 1: CHECK_TYPE_AND_SET_VALUE(radius_, ValueBase::TYPE_REAL);
+ case 2: CHECK_TYPE_AND_SET_VALUE(seed_, ValueBase::TYPE_INTEGER);
+ case 3: CHECK_TYPE_AND_SET_VALUE(speed_, ValueBase::TYPE_REAL);
+ case 4: CHECK_TYPE_AND_SET_VALUE(smooth_, ValueBase::TYPE_INTEGER);
}
return false;
}
{
return
type==ValueBase::TYPE_ANGLE ||
+ type==ValueBase::TYPE_BOOL ||
type==ValueBase::TYPE_COLOR ||
type==ValueBase::TYPE_INTEGER ||
type==ValueBase::TYPE_REAL ||