class RKB_TrapShapeCombineShapes(common.ulb:TrapShape) {
; A shape plug-in which combines two shapes
public:
func RKB_TrapShapeCombineShapes(Generic pparent)
TrapShape(pparent)
; True if function list is set to 'ident'
ShapeA = new @shapeA(this)
ShapeB = new @shapeB(this)
endfunc
float func Iterate(complex pz)
; Process Shape A
float fIndexA = ShapeA.Iterate(pz)
if (@fGradientRotateA > 0.0)
if (fIndexA > 1.0), fIndexA = 1.0, endif
fIndexA = ((fIndexA + @fGradientRotateA) % 1.0)
endif
fIndexA = fIndexA * @fScaleA
; Process Shape B
float fIndexB = ShapeB.Iterate(pz)
if (@fGradientRotateB > 0.0)
if (fIndexB > 1.0), fIndexB = 1.0, endif
fIndexB = ((fIndexB + @fGradientRotateB) % 1.0)
endif
fIndexB = fIndexB * @fScaleB
float fIndex = 0.0
; Put them together
if (@enCombineMode == "Ratio")
fIndex = fIndexA * @fRatio + fIndexB * (1.0 - @fRatio)
elseif (@enCombineMode == "A-B")
fIndex = fIndexA - fIndexB
elseif (@enCombineMode == "B-A")
fIndex = fIndexB - fIndexA
elseif (@enCombineMode == "A*B")
fIndex = fIndexA * fIndexB
elseif (@enCombineMode == "A/B")
fIndex = fIndexB / (fIndexA * @fStrength)
elseif (@enCombineMode == "min")
if (fIndexA < fIndexB), fIndex = fIndexA, else, fIndex = fIndexB, endif
elseif (@enCombineMode == "max")
if (fIndexA > fIndexB), fIndex = fIndexA, else, fIndex = fIndexB, endif
elseif (@enCombineMode == "sin/cos")
if (fIndexA > 1.0), fIndexA = 0.0, endif
if (fIndexB > 1.0), fIndexB = 0.0, endif
fIndex = (abs(sin(fIndexA * #pi)) + abs(cos(fIndexB * #pi)))/2
elseif (@enCombineMode == "sin/cos min")
if (fIndexA > 1.0), fIndexA = 0.0, endif
if (fIndexB > 1.0), fIndexB = 0.0, endif
fIndexA = abs(sin(fIndexA * #pi))
fIndexB = abs(cos(fIndexB * #pi))
if (fIndexA < fIndexB), fIndex = fIndexA, else, fIndex = fIndexB, endif
elseif (@enCombineMode == "sin/cos max")
if (fIndexA > 1.0), fIndexA = 0.0, endif
if (fIndexB > 1.0), fIndexB = 0.0, endif
fIndexA = abs(sin(fIndexA * #pi))
fIndexB = abs(cos(fIndexB * #pi))
if (fIndexA > fIndexB), fIndex = fIndexA, else, fIndex = fIndexB, endif
elseif (@enCombineMode == "A only")
fIndex = fIndexA
elseif (@enCombineMode == "B only")
fIndex = fIndexB
endif
return fIndex
endfunc
private:
TrapShape ShapeA
TrapShape ShapeB
default:
title = "Combine Shapes"
int param iVersion
default = 101
visible = false
endparam
param enCombineMode
caption = "Combine Mode"
enum = "Ratio" "A-B" "B-A" "A*B" "A/B" "min" "max" "sin/cos" \
"sin/cos min" "sin/cos max" "A only" "B only"
endparam
float param fRatio
caption = "Combine Ratio"
default = .5
min = 0
max = 1.0
visible = @enCombineMode == "ratio"
endparam
float param fStrength
caption = "Strength"
default = .1
visible = @enCombineMode == "A/B"
endparam
heading
caption="-- Shape A parameters --"
endheading
float param fScaleA
caption = "Scale Shape A"
default = 1.0
endparam
float param fGradientRotateA
caption = "Rotate Graident A"
default = 0.0
min = 0.0
max = 1.0
hint = "Rotates the gradient for Shape A. Values range from 0.0 to 1.0."
endparam
TrapShape param shapeA
caption = "Trap Shape A"
default = RKB_TrapShapeFlower
hint = "Selects first shape for the combination."
endparam
heading
caption="-- Shape B parameters --"
endheading
float param fScaleB
caption = "Scale Shape B"
default = 1.0
endparam
float param fGradientRotateB
caption = "Rotate Graident B"
default = 0.0
min = 0.0
max = 1.0
hint = "Rotates the gradient for Shape B. Values range from 0.0 to 1.0."
endparam
TrapShape param shapeB
caption = "Trap Shape B"
default = RKB_TrapShapeFlower
hint = "Selects second shape for the combination."
endparam
}