hue2R(H, S, L) = case S == 0.0: L else: hue2RGB( temp1(L, S), temp2(L, S), H + truncTo1000( 1.0/3.0 ) ) hue2G(H, S, L) = case S == 0.0: L else: hue2RGB( temp1(L, S), temp2(L, S), H) hue2B(H, S, L) = case S == 0.0: L else: hue2RGB( temp1(L, S), temp2(L, S), H - truncTo1000( 1.0 / 3.0 ) ) hue2RGB(v1, v2, vH ) = //Function Hue_2_RGB case vH < 0.0: hue2RGB(v1, v2, truncTo1000(vH + 1.0)) case vH > 1.0: hue2RGB(v1, v2, truncTo1000(vH - 1.0)) else: case truncTo1000(6.0 * vH) < 1.0: ( truncTo1000(v1 + ( v2 - v1 )) * truncTo1000(6.0 * vH) ) case truncTo1000(2.0 * vH) < 1.0: v2 case truncTo1000(3.0 * vH) < 2.0: ( (v1 + ( v2 - v1 )) * truncTo1000( ( 2.0 / 3.0 ) - vH) * 6.0 ) else: 0 temp2(l, sat) = case l < 0.5: l * (1+sat) else: (l+sat) - (l*sat) temp1(l, sat) = (2.0 * l) - temp2(l, sat) truncTo1000(val) = truncTo(val, 1000) truncTo100(val) = truncTo(val, 100) truncTo(val, order) = ((rint(val * order)) / order)
def getAttrFilterFunction(ce_instance, attr, value):
return lambda x: ce_instance.getAttribute(x, attr) == value
def getAttrContainingFilter(ce_instance, attr, value):
return lambda x: value in ce_instance.getAttribute(x, attr)
def getAttrExistsFilter(ce_instance, attr):
return lambda x: attr in ce_instance.getAttributeList(x)
# determines if shape is sidewalk
def getSidewalkFilter(ce_instance):
return lambda x: ce_instance.getUUID(x).__str__().endswith(":1") or ce_instance.getUUID(x).__str__().endswith(":2")
# determines if shape is street
def getStreetFilter(ce_instance):
return lambda x: ce_instance.getUUID(x).__str__().endswith(":0")
allShapes = ce.selection() myStreetsFilter = getStreetFilter(ce) onlyStreets = filter(myStreetsFilter, allShapes)
import misc: "misc.cga" Lot --> extrude(10) color(misc.RosyBrown1) Mass.
attr SCALE = 1000 attr R = 500 attr elevation = case sqrt( ( pow((u-0.5)*SCALE, 2) + pow((v-0.5)*SCALE, 2)) ) > R: 0.0 else: case sqrt(R*R - (pow((u-0.5)*SCALE, 2) + pow((v-0.5)*SCALE, 2))) < 0: 0 else: sqrt(R*R - (pow((u-0.5)*SCALE, 2) + pow((v-0.5)*SCALE, 2)))
The CE documentation talks about terrain layer attributes and functions... Here is an example of a spherical terrain:attr SCALE = 1000 attr R = 500 attr elevation = case sqrt( ( pow((u-0.5)*SCALE, 2) + pow((v-0.5)*SCALE, 2)) ) > R: 0.0 else: case sqrt(R*R - (pow((u-0.5)*SCALE, 2) + pow((v-0.5)*SCALE, 2))) < 0: 0 else: sqrt(R*R - (pow((u-0.5)*SCALE, 2) + pow((v-0.5)*SCALE, 2)))
attr SCALE = 1000 attr R = 500 attr elevation = case sqrt( ( pow((u-0.5)*SCALE, 2) + pow((v-0.5)*SCALE, 2)) ) > R: 0.0 else: sqrt(R*R - (pow((u-0.5)*SCALE, 2) + pow((v-0.5)*SCALE, 2)))
attr SCALE = 1000 attr R = 1500 attr elevation = case sqrt( ( pow((u-0.5)*SCALE, 2) + pow((v-0.5)*SCALE, 2)) ) > R: 0.0 else: case sqrt(R*R - (pow((u-0.5)*SCALE, 2) + pow((v-0.5)*SCALE, 2))) - 1430 < 0: 0 else: (sqrt(R*R - (pow((u-0.5)*SCALE, 2) + pow((v-0.5)*SCALE, 2))) - 1430) + elevationDelta
def getAttrFilterFunction(ce_instance, attr, value): return lambda x: ce_instance.getAttribute(x, attr) == value
>>> myFilter = getAttrFilterFunction(ce, "customAttr", "fantasticShape") >>> fantasticShapes = ce.getObjectsFrom(ce.scene, myFilter)
const stairStepUnitRise = 0.17
const stairStepUnitRun = 0.28
@Hidden
attr currentScopeSx = 0
## dummy, calling rule bellow with some defaults
## the level has, by default, 45% of the lenght of the shape in x
StairwayWithLevel(topColor, frontColor, levelColor) -->
StairwayWithLevel(topColor, frontColor, levelColor, 0, 0, 0)
StairwayWithLevel(topColor, frontColor, levelColor, levelDim, centerDim, displacement) -->
set(currentScopeSx, scope.sx)
## first, divide into level and two stair flight of stairs
split(x){
(0.45 * scope.sx) + levelDim:
StairwayLevel(levelColor, currentScopeSx*0.45+ levelDim, currentScopeSx) |
~1:
split(z){
~1 + displacement:
t(0, ((rint((currentScopeSx-(currentScopeSx*0.45+ levelDim)) / stairStepUnitRun)) - 1)*stairStepUnitRise, 0)
StairFlight(topColor, frontColor) |
centerDim:
NIL|
~1:
rotateScope(0, 180, 0)
StairFlight(topColor, frontColor)
}
}
StairwayLevel(levelColor, length, total) -->
t(0, ((rint((total-length) / stairStepUnitRun)) - 1)*stairStepUnitRise, 0)
s('1, stairStepUnitRise, '1)
i("builtin:cube")
comp(f){
top:
color(levelColor)
set(material.specular.r, 0)
set(material.specular.g, 0)
set(material.specular.b, 0)
set(material.shininess, 0)
set(material.opacity, 1)
SetMaterial("stairwaylevel")|
all:
SetMaterial("stairwaylevel")
}
StairFlight(topColor, frontColor) -->
split(x){
~stairStepUnitRun:
t(0, (split.index)*stairStepUnitRise, 0)
StairwayStep(topColor, frontColor)
|
{
stairStepUnitRun:
t(0, (split.index)*stairStepUnitRise, 0)
StairwayStep(topColor, frontColor)
}*
}
StairwayStep(topColor, frontColor) -->
s('1, stairStepUnitRise, '1)
i("builtin:cube")
comp(f){
top:
color(topColor)
set(material.specular.r, 0)
set(material.specular.g, 0)
set(material.specular.b, 0)
set(material.shininess, 0)
set(material.opacity, 1)
SetMaterial("stairwaystep")|
all:
color(frontColor)
set(material.specular.r, 0)
set(material.specular.g, 0)
set(material.specular.b, 0)
set(material.shininess, 0)
set(material.opacity, 1)
SetMaterial("stairwaystep")
}
SetMaterial(name) -->
set(material.name, name)
TerminalMaterial.
'/ce/rule/wallC': {
0: 0,
1: ["#FFFFFF", "#000000", "#FFFFFF", "#000000", "#FFFFFF", "#000000", "#FFFFFF", "#000000", "#FFFFFF", "#000000", "#FFFFFF", "#000000", "#FFFFFF", "#000000", "#FFFFFF", "#000000", "#FFFFFF", "#000000", "#FFFFFF", "#000000", "#FFFFFF", "#000000", "#FFFFFF", "#000000", "#FFFFFF"]
}
Hey Andre !
Cool work !
Why's the model changing to black each second step ?
Cheers !
Matt