#CityEngine #halfCircle #parkinglot #quartercircle #CGA
Looks like this:
Hi all, I am pretty new to CityEngine but I learned something that I didn't see any where else. How to make a trimmed half circle, in my case for parking lots and medians.
At first, I looked at the complete street code but never found out how it was creating the medians here:
I think those are created by the "street graphing" but I am not totally sure. I noticed that the texturing in the half-circle-top was always just concrete (not the offset curb with grass effect I was looking for).
To start, I used a 32 sided primitiveDisk, which makes a good looking "circle". I applied the curb offset first, wondering how it would handle the longest edge, as I wanted that discarded. I divided it in half using a '50/50 relative' split along the x axis, and discarded the unused half with a NIL. Next step is offsetting the object by half the length of the starting object using the translate function and moving it -scope.sx/2. And the last trick was finding the right face, which in my code I use a 32 sided disk split in half, which produces 18 faces after the offset. I used a comp(f) function for all 18 faces but then made face #17 (the one I wanted) a different shape. (Code below)
/**
* File: HalfCirclewCurb.cga
* Created: 2 Jan 2020 14:32:08 GMT
* Author: bwamsley
*/
version "2019.1"
const Shift = (scope.sx /2)
@Start
halfCircleSpace-->
alignScopeToGeometry(yUp,0,0)
primitiveDisk(32)
Circle
Circle-->
offset(-1)
split(x){'.5 : NIL
|'.5 : halfCircle}
halfCircle-->
translate(rel,scope,-Shift,0,0)
curbMaker
pavement-->
color(0,1,0)
curbMaker-->
comp(f){17: pavement2
|0 : curb
|1 : curb
|2 : curb
|3 : curb
|4 : curb
|5 : curb
|6 : curb
|7 : curb
|8 : curb
|9 : curb
|10 : curb
|11 : curb
|12 : curb
|13 : curb
|14 : curb
|15 : curb
|16 : curb}
pavement2-->
color(0,1,1)
curb-->
extrude(1)
color(0,0,1)
SquareSpace-->
comp(f){top: textureTop
|side: Sides.}
textureTop-->
split(x){1: curb
|~1: curbTexture
|1: curb}
curbTexture-->
color(0,2,1)
I intend to incorporate this into my parking lot code which is growing in complexity each day:
This picture of my parking lot does not have the half circle with curb yet, but it will once I get my "splits" and conditional rules all set up.
Next Steps:
I'm curious if I can use another split, translate and/or scale function to create a quarter circle.
Also curious if I can use the scale function to fill the "circleSpace" back up to full (instead of half).
So even though we don't have arc functions yet, I believe there is still a lot that can be done with half circles (and maybe quarter-circles).
Hope this helps someone!
Update: Quarter Circle
/**
* File: QuarterCirclewCurb.cga
* Created: 2 Jan 2020 14:32:08 GMT
* Author: bwamsley
*/
version "2019.1"
const ShiftX = (scope.sx /2)
const ShiftZ = (scope.sz /2)
@Start
halfCircleSpace-->
alignScopeToGeometry(yUp,0,0)
primitiveDisk(32)
Circle
Circle-->
offset(-1)
split(x){'.5 : NIL
|'.5 : halfCircle}
halfCircle-->
split(z){'.5 : NIL
|'.5 : quarterCircle}
quarterCircle-->
translate(rel,scope,-ShiftX,0,-ShiftZ)
curbMaker
curbMaker-->
comp(f){0 : curb
|1 : curb
|2 : curb
|3 : curb
|4 : curb
|5 : curb
|6 : curb
|7 : curb
|8 : curb
|9 : GrassyArea}
GrassyArea-->
color(0,1,1)
curb-->
extrude(1)
color(0,0,1)
Update#2
Adding a simple s(ShiftX*2,0,ShiftZ*2) under the translate produces this:
quarterCircle-->
translate(rel,scope,-ShiftX,0,-ShiftZ)
s(ShiftX*2,0,ShiftZ*2)
curbMaker
Imagine the possibilities for this guy!!! Building sidewalk borders, planter borders, etc.
Extra: parking lot with half circles with curbs (need to tweak the textures still).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.