Peyep CGA 函数参考几何创建 · 2026.1
版本首页查看 demo →
← 返回 2026.1 分类导航

几何创建 Geometry Creation · 18 个函数

从初始地块生成体块:拉伸、包络、屋顶、基础图元等

i native ✓ cpp-fast ✓ 已验证 145 条 · silver 官方文档 ↗ #
插入外部资产 / 几何到当前形状(官方操作名为 i)
签名(4 种重载)
i(filePath)
i(filePath, upAxisOfGeometry)
i(filePath, upAxisOfGeometry, insertMode)
i(filePath, upAxisOfGeometry, insertMode, cleanupMode)
参数说明
参数类型说明
filePathstringName of the geometry asset to insert. See Asset and texture search for information about search locations.
官方说明(英文原文)

The i operation reads a geometry asset (3D model, polygon mesh) from a file and inserts it into the scope of the current shape. The asset is transformed such that its bounding box coincides with the scope.

If one or more of the scope's sizes sx, sy and sz (i.e. width, height or depth) are zero the scope is modified as follows:

  • If all three sizes of the scope are zero, such a point-like scope serves as origin for the asset to be inserted. Therefore, the size vector of the scope is set to the sizes of the asset’s bounding box i.e. scope.sx = asset.sx, scope.sy = asset.sy and scope.sz = asset.sz. Similarly, the scope is translated with the values from the asset, i.e. scope.tx += asset.tx , scope.ty += asset.ty and scope.tz += asset.tz. As a consequence, the inserted asset has not been modified and its original dimensions are completely preserved.
  • If two sizes are zero, such a line-like scope is modified relative to the non-zero size. For example, if only the height (scope.sy) is non-zero, the following scaling value is calculated: scalexz = scope.sy/asset.sy. The size modifications are then: scope.sx = scalexz*asset.sx and scope.sz = scalexz*asset.sz. Accordingly, the position of the scope is modified for the two corresponding axes with scope.tx +=scalexz*asset.tx and scope.tz += scalexz*asset.tz. Thus the inserted asset is uniformly scaled i.e. the proportions of the asset are completely preserved.
  • If one of the sizes is zero, the scope's size is modified relative to the average of the two non-zero sizes. For example, if the depth (scope.sz) is zero, the following calculation is performed: scope.sz = (scope.sx/asset.sx + scope.sy/asset.sy)*0.5*asset.sz. Note that the position of the scope is not modified.
Note:
官方示例(共 7 个,展示前 3 个) · 点击展开
Lot-->
   extrude(47)
   comp(f) { side : Facade  
           | top  :  X }	
	
Facade-->
   split(y) { { ~1 : X 
              | ~8 : Floor }* 
            | ~1   : X }
			   
Floor-->
   split(x) { { ~1 : X 
              | ~5 : Window }* 
            | ~1   : X }
Window-->
   i("window.obj")
Head-->
   s(0,0,0)	
   i("beethoven.obj")
我方已验证示例:learning case #78(verified_silver)· 点击展开代码 · 示例过大,请复制源码到 demo 运行
/**
 * File:    Fence_On_Graph.cga
 * Created: 18 Nov 2015 17:11:40 GMT
 * Author:  Esri R&D Center Zurich
 */

/*

Input shape:  street shape (shape with UVs), street width >= base_depth

Fences are created along the u direction of the street shape.

Notes on Occlusion:

* Occlusion Labels:  The fence parts (post, middle, base post, base middle, upper post, upper middle)
  are each labeled with the given occlusionLabel.  These labeled parts are meant to be occluders which
  can be found when te…
extrude native ✓ cpp-fast ✓ 已验证 594 条 · gold 官方文档 ↗ #
沿高度方向把当前面拉伸为体块
签名(2 种重载)
extrude(distance)
extrude(extrusionType, distance)
参数说明
参数类型说明
distancefloatHow many units to extrude.
官方说明(英文原文)

The extrude operation extrudes the shape. Each face polygon of all meshes in the geometry asset is taken and extruded along the face normal or a given direction as specified by the extrusion type. The scope orientation is set in the following way:

  • x-axis direction is kept as much as possible (old x-axis is projected to the plane orthogonal to extrusion direction).
  • y-axis along the extrusion direction.
  • z-axis normal to the two above.

The scope's sizes are adjusted to tightly fit the extruded geometry. If distance is negative, the scope.sy attribute will be negative.

Texture coordinates are inherited from the shape.

Note:
Edges can also be extruded, e.g., when working on shapes created from comp(e|fe) . See examples.

Component tags

The operation automatically applies semantic component tags to the resulting face components:

"extrude.bottom"

"extrude.side.outer"

"extrude.side.inner"

"extrude.top"

Blue: original face.

Yellow: side faces.

Red: side faces from holes.

Green: extruded face.

For more information on working with component tags, refer to:

官方示例(共 11 个,展示前 3 个) · 点击展开
Lot --> extrude(10)
Lot --> extrude(face.normal,10)
Lot --> extrude(vertex.normal,10)
我方已验证示例:基础挤出 + 颜色(verified_gold)· 点击展开代码 · 在 demo 中运行 →
@Range(min=0, max=20, step=0.5)
attr height = 10
attr roofColor = "#333333"
@StartRule
Lot -->
primitiveQuad(7, 15)
extrude(height)
color(1,0.5,0.2)
comp(f){side:Facade|top:Roof}
Facade --> split(y) { ~1 : Floor }*
Floor --> color(0.7,0.75,0.8)
Roof --> roofHip(30) color(roofColor)
envelope native ✓ cpp-fast ✓ 已验证 12 条 · gold 官方文档 ↗ #
按规划参数(退线、限高等)生成建筑包络体
签名(5 种重载)
envelope(direction, maxHeight, frontBaseHeight, frontAngle)
envelope(direction, maxHeight, frontBaseHeight, frontAngle, backBaseHeight, backAngle)
envelope(direction, maxHeight, frontBaseHeight, frontAngle, backBaseHeight, backAngle, sideBaseHeight, sideAngle)
envelope(direction, maxHeight, frontBaseHeight, frontAngle, backBaseHeight, backAngle, rightBaseHeight, rightAngle, leftBaseHeight, leftAngle)
envelope(direction, maxHeight, baseHeights, angles)
参数说明
参数类型说明
directionselector{ normal | world.up }—Direction along which the envelope is erected.
maxHeightfloatMaximum height of the envelope in meters. If this height is reached, the volume is cut and sealed horizontally.
frontBaseHeightfloatBase height of the corresponding side in meters.
frontAnglefloatSlope angle of corresponding side in degrees.
baseHeightsfloat[]Base heights, one value per edge.
anglesfloat[]Slope angles, one value per edge.
官方说明(英文原文)

The envelope operation creates a building envelope above each face of the current shape's geometry. Each edge of the face is classified according to the street.front, street.back, street.right, street.left, street.side selectors. Sides with the according baseHeights are then built perpendicular to the face. Finally, sloped planes are added at the top of each side, with the according slope angle. Evaluation of the street.xxx selectors is based on the streetWidth attribute, see Auto-generated street width attributes. If the attribute is not available, component selection falls back to the object.xxx selectors.

Per edge control

One version of envelope allows for specification of baseHeights and angles per edge via arrays. The array must be in face-edge order, i.e. the first element is for the first edge of the first face, the second element is for the second edge of the first face, and so on. Shared edges are considered separately for each face. If the array does not contain enough elements, default values (0 for baseHeight and 90 degrees for the angle) are used. This allows to e.g. write

envelope(direction, maxHeight, frontBaseHeight, frontAngle, backBaseHeight, backAngle)

as

envelope(direction, maxHeight, 
      comp(fe) { street.front = frontBaseHeight | street.back = backBaseHeight }, 
      comp(fe) { street.front = frontAngle | street.back = backAngle | all = 90 })
Basic envelope() operation parameters. The baseHeight and angle parameters of the other sides are analogue.

Example of the street.front, street.back, street.right, street.left, street.side selectors are applied on a lot of a block (with auto-generated streetWidth attributes).

Component tags

The operation automatically applies semantic component tags to the resulting face components:

"envelope.bottom"

"envelope.side.base"

"envelope.side.slope"

"envelope.side.inner"

"envelope.top"

Blue: original face.

Yellow: vertical base faces.

Orange: sloped faces.

Red: side faces from holes.

Green: top face at max height.

For more information on working with component tags, refer to:

官方示例 · 点击展开
Lot-->
  setback(10) { street.front : color(0,1,0) 
                               FrontYard | 
                remainder    : Building   }	              

Building-->
  envelope(normal, 50, 15, 30)
我方已验证示例:envelope(verified_gold)· 点击展开代码 · 在 demo 中运行 →
@StartRule
Lot -->
primitiveQuad(7, 15)
extrude(4)
envelope(45)
color(0.7, 0.8, 0.9)
taper native ✓ cpp-fast ✓ 已验证 9 条 · silver 官方文档 ↗ #
对体块向上收分(渐缩)
签名(1 种重载)
taper(height)
参数说明
参数类型说明
heightfloatHow many units to extrude.
官方说明(英文原文)

The taper operation tapers the shape (i.e. forms a pyramid over a polygon). The first polygon of the first mesh in the geometry asset is taken and tapered along the face normal through the polygon's center of gravity. The scope orientation is set in the following way:

  • x-axis direction is kept as much as possible (old x-axis is projected to the face plane)
  • y-axis along the face normal (taper direction)
  • z-axis normal to the two above

The scope's sizes are adjusted to tightly fit the extruded geometry. If height is < 0, the scope.sy attribute will be < 0 and the taper will be downwards.

Component tags

The operation automatically applies semantic component tags to the resulting face components:

"taper.bottom"

"taper.side"

Blue: original face.

Yellow: side faces.

For more information on working with component tags, refer to:

官方示例 · 点击展开
Lot-->		
   taper(10)
我方已验证示例:learning case #107(verified_silver)· 点击展开代码 · 在 demo 中运行 →
@Description("CityEngine CGA 几何操作函数示例 - extrude / comp / roof / offset / mirror / normals")
@Group("几何操作")
@Order(32)

// ============================================================
// 几何操作 Geometry Operations
// 演示 extrude, comp, roof*, offset, envelope, mirror, normals 等
// ============================================================

@StartRule
Lot --> OperationShowcase

OperationShowcase -->
    split(x) { ~8: ExtrudeDemo
             | ~8: RoofHipDemo
             | ~8: RoofGableDemo
     …
roofGable native ✓ cpp-fast ✓ 已验证 61 条 · gold 官方文档 ↗ #
生成双坡(山墙)屋顶
签名(9 种重载)
roofGable(angle)
roofGable(angle, overhangX)
roofGable(angle, overhangX, overhangY)
roofGable(angle, overhangX, overhangY, even)
roofGable(angle, overhangX, overhangY, even, index)
roofGable(valueType, value)
roofGable(valueType, value, overhangX)
roofGable(valueType, value, overhangX, overhangY)
roofGable(valueType, value, overhangX, overhangY, even)
参数说明
参数类型说明
anglefloatAngle of the roof-planes (generation byAngle).
overhangXfloatOverhang distance for overhangs perpendicular to ridges, measured perpendicular to the shape edges (on the roof).
overhangYfloatOverhang distance for overhangs in the direction of the ridges, measured perpendicular to the shape edges (on the roof).
evenboolWhether to make the roof gable even or not. If true, non-planar faces can originate.
indexfloatEdge index to control the orientation of the ridge.
valueTypeselector{ byAngle | byHeight }—Type of roof generation.
valuefloatAngle or height of the roof-planes as specified by valueType.
官方说明(英文原文)

The roofGable operation builds a gable roof perpendicular to each face of the current shape's geometry. The orientation of the ridges is automatically computed (except in the indexed case). At all non-ridge (eave) edges, a plane is generated with a given angle or height wrt. the polygon plane. The planes are cut with each other to form the roof faces:

  • If overhangX is set, the roof faces overlap along the eave edges by this distance. Overhang distances are measured perpendicular to the edges (on the roof planes).
  • If overhangY is set, the roof faces overlap in the direction of the ridges by this distance. Overhang distances are measured perpendicular to the shape edges (on the roof planes).
  • If even is set to true, the gable edges are forced to be horizontal. In this case, non-planar roof faces can originate.
  • If index is set, the ridge is forced to be oriented in the direction of the edge index.
    Caution:

    This only works on convex shapes with a single face. The even parameter is neglected.

Note:

The connectivity of the roof mesh is optimized for trim plane generation to cut bricks inserted into the roof planes (see examples below).

Scope

The scope orientation is set in the following way:

  • x-axis direction is kept as much as possible (old x-axis is projected to the plane of the first face).
  • y-axis along the face normal of the first face.
  • z-axis normal to the two above.

The scope's sizes are adjusted to tightly fit the extruded geometry.

Component tags

The operation automatically applies semantic component tags to the resulting face components:

"roof.bottom"

"roof.side"

"roof.top"

Blue: original face.

Yellow: pediment faces.

Green: roof faces.

For more information on working with component tags, refer to:

官方示例(共 4 个,展示前 3 个) · 点击展开
Lot  --> 
   extrude(10) Mass
   
Mass --> 
   comp(f) { top : Top 
           | all : X }
		   
Top  --> 
   roofGable(30, 2, 1) Roof
Roof --> 
   set(trim.horizontal, true)
   comp(f) { all : X }
Lot  --> 
   extrude(10) Mass
   
Mass --> 
   comp(f) { top : Top 
           | all : X }
		   
Top  --> 
   roofGable(30, 1, 1, false) Roof
我方已验证示例:roofGable(verified_gold)· 点击展开代码 · 在 demo 中运行 →
@StartRule
Lot -->
primitiveQuad(7, 15)
extrude(5)
comp(f) { top: Roof | side: Wall }
Roof --> roofGable(35) color(0.6, 0.3, 0.2)
Wall --> color(0.75, 0.72, 0.68)
roofHip native ✓ cpp-fast ✓ 已验证 99 条 · gold 官方文档 ↗ #
生成四坡屋顶
签名(6 种重载)
roofHip(angle)
roofHip(angle, overhang)
roofHip(angle, overhang, even)
roofHip(valueType, value)
roofHip(valueType, value, overhang)
roofHip(valueType, value, overhang, even)
参数说明
参数类型说明
anglefloatAngle of the roof-planes generation (byAngle).
overhangfloatOverhang distance for overhangs perpendicular to ridges, measured perpendicular to the shape edges (on the roof).
evenboolWhether to make the roof hip even or not. If true, non-planar faces originate.
valueTypeselector{ byAngle | byHeight }—Type of roof generation.
valuefloatAngle or height of the roof-planes as specified by valueType.
官方说明(英文原文)

The roofHip operation builds a hip roof perpendicular to each face of the current shape's geometry. At every edge, a plane is generated with a given angle or height wrt. the polygon plane. All planes are cut with each other to form the roof faces.

If overhang is set, the roof faces overlap the original shape by this distance. Overhang distances are measured perpendicular to the shape edges (on the roof planes).

If even is set to true, the hip edges are forced to be horizontal. In this case, non-planar roof faces originate.

Note:

The connectivity of the roof mesh is optimized for trim plane generation to cut bricks inserted into the roof planes (see examples below).

Scope

The scope orientation is set in the following way:

  • x-axis direction is kept as much as possible (old x-axis is projected to the plane of the first face).
  • y-axis along the face normal of the first face.
  • z-axis normal to the two above.

The scope's sizes are adjusted to tightly fit the extruded geometry.

Component tags

The operation automatically applies semantic component tags to the resulting face components:

"roof.bottom"

"roof.top"

Blue: original face.

Green: roof faces.

For more information on working with component tags, refer to:

官方示例(共 4 个,展示前 3 个) · 点击展开
Lot  --> 
   extrude(10) Mass
   
Mass --> 
   comp(f) { top : Top 
           | all : X }
		   
Top  --> 
   roofHip(30, 2) Roof
Roof --> 
   set(trim.horizontal, true)
   comp(f) { all : X }
Lot  --> 
   extrude(10) Mass
   
Mass --> 
   comp(f) { top : Top 
           | all : X }
		   
Top  --> 
   roofHip(45, 1, false) Roof
我方已验证示例:基础挤出 + 颜色(verified_gold)· 点击展开代码 · 在 demo 中运行 →
@Range(min=0, max=20, step=0.5)
attr height = 10
attr roofColor = "#333333"
@StartRule
Lot -->
primitiveQuad(7, 15)
extrude(height)
color(1,0.5,0.2)
comp(f){side:Facade|top:Roof}
Facade --> split(y) { ~1 : Floor }*
Floor --> color(0.7,0.75,0.8)
Roof --> roofHip(30) color(roofColor)
roofPyramid native ✓ cpp-fast ✓ 已验证 23 条 · gold 官方文档 ↗ #
生成金字塔形屋顶
签名(2 种重载)
roofPyramid(angle)
roofPyramid(valueType, value)
参数说明
参数类型说明
anglefloatAngle of the roof-planes generation (byAngle).
valueTypeselector{ byAngle | byHeight }—Type of roof generation.
valuefloatAngle or height of the roof-planes as specified by valueType.
官方说明(英文原文)

The roofPyramid operation builds a pyramid roof perpendicular to each face of the current shape's geometry. The polygon center (average of all vertices) gets extruded along the face normal by the given height and connected to all polygon vertices. The new triangles are the roof faces. If an angle is given the height is chosen such that the angle between roof triangle 1 and the polygon is as specified.

Note:

The connectivity of the roof mesh is optimized for trim plane generation to cut bricks inserted into the roof planes (see examples below).

Scope

The scope orientation is set in the following way:

  • x-axis direction is kept as much as possible (old x-axis is projected to the plane of the first face).
  • y-axis along the face normal of the first face.
  • z-axis normal to the two above.

The scope's sizes are adjusted to tightly fit the extruded geometry.

Component tags

The operation automatically applies semantic component tags to the resulting face components:

"roof.bottom"

"roof.top"

Blue: original face.

Green: roof faces.

For more information on working with component tags, refer to:

官方示例 · 点击展开
Lot  --> 
   extrude(10) Mass
   
Mass --> 
   comp(f) { top : Top 
           | all : X }
		   
Top  --> 
   roofPyramid(30) Roof
Roof --> 
   comp(f) { all : X }
我方已验证示例:roofPyramid(verified_gold)· 点击展开代码 · 在 demo 中运行 →
@StartRule
Lot -->
primitiveQuad(7, 15)
extrude(5)
comp(f) { top: Roof | side: Wall }
Roof --> roofPyramid(45) color(0.6, 0.3, 0.2)
Wall --> color(0.75, 0.72, 0.68)
roofRidge native ✗ cpp-fast ✓ 已验证 9 条 · silver 官方文档 ↗ #
按脊线参数生成坡屋顶
签名(1 种重载)
roofRidge(valueType, value)
参数说明
参数类型说明
valueTypeselector{ byAngle | byHeight }—Type of roof generation.
valuefloatAngle or height of the roof-planes as specified by valueType.
官方说明(英文原文)

The roofRidge operation builds a roof perpendicular to each face of the current shape's geometry. In contrast to the roofHip operation and the roofGable operation only one ridge is constructed. On arbitrary shapes no hips or gables are created but the shape outline becomes part of two angled roof planes.

The ridge is oriented wrt. the x-axis of the scope. Namely, the resulting ridge is parallel to the scope's x-axis projected to the face plane. To orient the ridge align the scope using operations like alignScopeToGeometry, alignScopeToGeometryBBox or rotateScope.

Note:

The connectivity of the roof mesh is optimized for trim plane generation to cut bricks inserted into the roof planes (see examples below).

Scope

The scope orientation is set in the following way:

  • x-axis direction is kept as much as possible (old x-axis is projected to the plane of the first face).
  • y-axis along the face normal of the first face.
  • z-axis normal to the two above.

The scope's sizes are adjusted to tightly fit the extruded geometry.

Component tags

The operation automatically applies semantic component tags to the resulting face components:

"roof.bottom"

"roof.side.outer"

"roof.side.inner"

"roof.top"

Blue: original face.

Yellow: side faces.

Red: side faces from holes.

Green: roof faces.

For more information on working with component tags, refer to:

官方示例(共 5 个,展示前 3 个) · 点击展开
Lot  --> extrude(10) Mass
Mass --> comp(f) { top : Top | side = Sides. }
Top  --> roofRidge(byAngle, 30) Roof
 Roof --> set(trim.horizontal, true)
         comp(f) { all : Face. }
Lot  --> extrude(10) Mass
Mass --> comp(f) { top : Top | side = Sides. }
Top  --> alignScopeToGeometryBBox(xy)
         roofRidge(byAngle, 30)
我方已验证示例:learning case #184(verified_silver)· 点击展开代码 · 在 demo 中运行 →
/* roofRidge operation example */
Lot -->
  extrude(8)
  roofRidge("height", 4)
  color("#cc8844")
roofShed native ✓ cpp-fast ✓ 已验证 21 条 · silver 官方文档 ↗ #
生成单坡屋顶
签名(4 种重载)
roofShed(angle)
roofShed(angle, index)
roofShed(valueType, value)
roofShed(valueType, value, index)
参数说明
参数类型说明
anglefloatAngle of the roof-plane generation (byAngle).
indexfloatEdge index (thus integral value) to specify the orientation of the shed roof.
valueTypeselector{ byAngle | byHeight }—Type of roof generation.
valuefloatAngle or height of the roof-planes as specified by valueType.
官方说明(英文原文)

The roofShed operation builds a shed roof perpendicular to each face of the current shape's geometry. At edge index (default value 0), a plane is generated with a given angle or height wrt. the polygon plane.

If index is set, the roof plane is oriented to the specified edge.

Note:

The connectivity of the roof mesh is optimized for trim plane generation to cut bricks inserted into the roof planes (see examples below).

Scope

The scope orientation is set in the following way:

  • x-axis direction is kept as much as possible (old x-axis is projected to the plane of the first face).
  • y-axis along the face normal of the first face.
  • z-axis normal to the two above.

The scope's sizes are adjusted to tightly fit the extruded geometry.

Component tags

The operation automatically applies semantic component tags to the resulting face components:

"roof.bottom"

"roof.side.outer"

"roof.side.inner"

"roof.top"

Blue: original face.

Yellow: side faces.

Red: side faces from holes.

Green: roof faces.

For more information on working with component tags, refer to:

官方示例 · 点击展开
Lot  --> 
   extrude(10) Mass
   
Mass --> 
   comp(f) { top : Top 
           | all : X }
		   
Top  --> 
   roofShed(10, 3) Roof
Roof --> 
   comp(f) { all : X }
我方已验证示例:learning case #166(verified_silver)· 点击展开代码 · 在 demo 中运行 →
version "2023.1"

attr naveHeight = 10
attr aisleHeight = 6
attr towerHeight = 14
attr spireHeight = 5

@StartRule
Lot -->
	split(x) { ~1 : Aisle | ~2 : Nave | ~1 : Aisle }

Nave -->
	color("#D3D3D3")
	extrude(naveHeight)
	primitiveCube()
	NaveRoof

NaveRoof -->
	color("#696969")
	roofGable(naveHeight * 0.3, 0.3, 0.5)

Aisle -->
	color("#C0C0C0")
	extrude(aisleHeight)
	primitiveCube()
	AisleRoof

AisleRoof -->
	color("#808080")
	roofShed(aisleHeight * 0.25, 0.5)

Tower -->
	color("#A9A9A9")
	ext…
offset native ✓ cpp-fast ✓ 已验证 129 条 · gold 官方文档 ↗ #
平面轮廓向内 / 向外偏移
签名(2 种重载)
offset(distance)
offset(distance, keepFaces)
参数说明
参数类型说明
distancefloatThe offset distance, negative or positive.
keepFacesselector{ all | inside | border }—Selects which faces to keep. all is default.
官方说明(英文原文)

The offset operation constructs offset polygons at distance distance for each face of the current shape's geometry. Depending on the sign of the parameter, offset polygons are constructed in the interior (negative sign) or in the exterior (positive sign), respectively.

Note:

The resulting shape contains both the offset polygons and the border faces (that is the difference between the original faces and the offset polygons). If only the offset polygons are needed, the corresponding faces can simply be extracted by using a component split (see examples below). Alternatively, an offset selector can be supplied as a second parameter.

Scope

The scope's size is adapted to the new geometry.

Occluder shape

In case an offset selector is applied an occluder shape is automatically generated before the offset is applied. The occluder shape is made available for unlabeled occlusion queries.

Compontent tags

The operation propagates existing component tags to the resulting geometry. See the section about tag propagation for more information on working with component tags.

官方示例 · 点击展开
attr blue    = "#3957A5"
attr yellow  = "#F2BB1D"

Lot --> offset(-3) A
A   --> comp(f) { inside: I | border: O }
I   --> color(blue)
O   --> color(yellow)
我方已验证示例:offset(verified_gold)· 点击展开代码 · 在 demo 中运行 →
@StartRule
Lot -->
primitiveQuad(7, 15)
extrude(0.2)
offset(-1)
color(0.8, 0.8, 0.9)
primitiveQuad native ✓ cpp-fast ✓ 已验证 150 条 · gold 官方文档 ↗ #
创建矩形面片
签名(2 种重载)
primitiveQuad()
primitiveQuad(width, length)
参数说明
参数类型说明
widthfloatWidth of the quad.
lengthfloatLength of the quad.
官方说明(英文原文)

The primitiveQuad operation inserts a quad geometry into the scope of the current shape.

  • If width and length aren't given the bounding box coincides with the scope. Zero scope sizes are handled the same way as in the i operation.
  • If dimensions are specified the quad is positioned in the xz-center of the scope lying on y=0.

If one scope size is zero while the 2 other sizes are not zero the quad will be inserted with respect to the plane defined by the valued scope sizes.

The quad has texture coordinates on the first texture layer (COLORMAP).

官方示例 · 点击展开
Lot-->
   rotateScope(0, 0, 90) // scope.sx is 0
   primitiveQuad()
   texture("builtin:uvtest.png")
Lot-->
   rotateScope(0, 0, 90) // scope.sx is 0
   primitiveQuad(10,20)
   texture("builtin:uvtest.png")
我方已验证示例:基础挤出 + 颜色(verified_gold)· 点击展开代码 · 在 demo 中运行 →
@Range(min=0, max=20, step=0.5)
attr height = 10
attr roofColor = "#333333"
@StartRule
Lot -->
primitiveQuad(7, 15)
extrude(height)
color(1,0.5,0.2)
comp(f){side:Facade|top:Roof}
Facade --> split(y) { ~1 : Floor }*
Floor --> color(0.7,0.75,0.8)
Roof --> roofHip(30) color(roofColor)
primitiveDisk native ✓ cpp-fast ✓ 已验证 15 条 · silver 官方文档 ↗ #
创建圆形面片
签名(3 种重载)
primitiveDisk()
primitiveDisk(nVertices)
primitiveDisk(nVertices, radius)
参数说明
参数类型说明
nVerticesfloatNumber of vertices at the boundary of the disk. There must be at least 3 vertices. The default value is 16.
radiusfloatRadius of the disk.
官方说明(英文原文)

The primitiveDisk operation inserts a disk geometry into the scope of the current shape.

  • If the radius isn't given the bounding box coincides with the scope. Zero scope sizes are handled the same way as in the i operation.
  • If radius is specified the disk is positioned in the xz-center of the scope lying on y=0.

If one scope size is zero while the 2 other sizes are not zero the disk will be inserted with respect to the plane defined by the valued scope sizes.

The disk has texture coordinates on the first texture layer (COLORMAP).

官方示例 · 点击展开
Lot-->
   rotateScope(-90, 0, 0) // scope.sz is 0
   primitiveDisk()
   texture("builtin:uvtest.png")
Lot-->
   rotateScope(-90, 0, 0) // scope.sz is 0
   primitiveDisk(8,10)
   texture("builtin:uvtest.png")
我方已验证示例:learning case #168(verified_silver)· 点击展开代码 · 在 demo 中运行 →
version "2023.1"

attr baseHeight = 1.5
attr hallHeight = 7
attr domeHeight = 5
attr minaretHeight = 12

@StartRule
Lot -->
	extrude(baseHeight)
	color("#F5F5DC")
	primitiveCube()
	Courtyard

Courtyard -->
	split(x) { ~3 : PrayerHall | ~1 : Minaret }

PrayerHall -->
	color("#FFF8DC")
	extrude(hallHeight)
	primitiveCube()
	Dome

Dome -->
	color("#48D1CC")
	primitiveSphere(2.5)
	Lantern

Lantern -->
	color("#FFD700")
	primitiveCylinder(6, 0.2, 1)

Minaret -->
	color("#F5F5DC")
	extrude(minaretHeig…
primitiveCube native ✓ cpp-fast ✓ 已验证 279 条 · gold 官方文档 ↗ #
创建立方体
签名(2 种重载)
primitiveCube()
primitiveCube(width, height, depth)
参数说明
参数类型说明
widthfloatWidth of the cube.
heightfloatHeight of the cube.
depthfloatDepth of the cube.
官方说明(英文原文)

The primitiveCube operation inserts a cube geometry into the scope of the current shape.

  • If no width, height and depth are given the bounding box coincides with the scope. Zero scope sizes are handled the same way as in the i operation.
  • If dimensions are specified the cube is positioned in the xz-center of the scope lying on y=0.

The cube has texture coordinates on the first texture layer (COLORMAP).

官方示例 · 点击展开
Lot-->
   primitiveCube()
   texture("builtin:uvtest.png")
Lot-->
   primitiveCube(10,15,20)
   texture("builtin:uvtest.png")
我方已验证示例:primitiveCube(verified_gold)· 点击展开代码 · 在 demo 中运行 →
@StartRule
Lot --> primitiveCube(4, 3, 2) color(0.6, 0.7, 0.8)
primitiveSphere native ✓ cpp-fast ✓ 已验证 25 条 · gold 官方文档 ↗ #
创建球体
签名(3 种重载)
primitiveSphere()
primitiveSphere(sides, divisions)
primitiveSphere(sides, divisions, radius)
参数说明
参数类型说明
sidesfloatNumber of subdivisions along latitude of the sphere. There must be at least 3 sides. The default value is 16.
divisionsfloatNumber of subdivisions along longitude of the sphere. There must be at least 3 sides. The default value is 16.
radiusfloatRadius of the sphere.
官方说明(英文原文)

The primitiveSphere operation inserts a sphere geometry into the scope of the current shape.

  • If radius isn't given the bounding box coincides with the scope. Zero scope sizes are handled the same way as in the i operation.
  • If radius is specified the sphere is positioned in the xz-center of the scope lying on y=0.

The sphere has texture coordinates on the first texture layer (COLORMAP).

官方示例 · 点击展开
Lot-->
   primitiveSphere()
   texture("builtin:uvtest.png")
Lot-->
   primitiveSphere(8,4,10)
   texture("builtin:uvtest.png")
我方已验证示例:基础体:球 / 圆柱(verified_gold)· 点击展开代码 · 在 demo 中运行 →
@StartRule
Lot --> primitiveSphere(2) Sphere
Lot2 --> primitiveCylinder(1,3) Cyl
Sphere --> t(-3,1.5,0) color(0.8,0.3,0.3)
Cyl --> t(3,1.5,0) color(0.3,0.5,0.8)
primitiveCylinder native ✓ cpp-fast ✓ 已验证 30 条 · gold 官方文档 ↗ #
创建圆柱体
签名(3 种重载)
primitiveCylinder()
primitiveCylinder(sides)
primitiveCylinder(sides, radius, height)
参数说明
参数类型说明
sidesfloatNumber of subdivisions of the cylindrical surface. There must be at least 3 sides. The default value is 16.
radiusfloatRadius of the cylinder.
heightfloatHeight of the cylinder.
官方说明(英文原文)

The primitiveCylinder operation inserts a cylinder geometry into the scope of the current shape.

  • If radius and height aren't given the bounding box coincides with the scope. Zero scope sizes are handled the same way as in the i operation.
  • If dimensions are specified the cylinder is positioned in the xz-center of the scope lying on y=0.

The cylinder has texture coordinates on the first texture layer (COLORMAP).

官方示例 · 点击展开
Lot-->
   primitiveCylinder()
   texture("builtin:uvtest.png")
Lot-->
   primitiveCylinder(8,10,15)
   texture("builtin:uvtest.png")
我方已验证示例:primitiveCylinder(verified_gold)· 点击展开代码 · 在 demo 中运行 →
@StartRule
Lot --> primitiveCylinder(16, 1.5, 4) color(0.7, 0.7, 0.8)
primitiveCone native ✓ cpp-fast ✓ 已验证 8 条 · gold 官方文档 ↗ #
创建圆锥体
签名(3 种重载)
primitiveCone()
primitiveCone(sides)
primitiveCone(sides, radius, height)
参数说明
参数类型说明
sidesfloatNumber of subdivisions of the cone surface. There must be at least 3 sides. The default value is 16.
radiusfloatRadius of the cone.
heightfloatHeight of the cone.
官方说明(英文原文)

The primitiveCone operation inserts a cone geometry into the scope of the current shape.

  • If no radius and height are given the bounding box coincides with the scope. Zero scope sizes are handled the same way as in the i operation.
  • If dimensions are specified the cone is positioned in the xz-center of the scope lying on y=0.

The cone has texture coordinates on the first texture layer (COLORMAP).

官方示例 · 点击展开
Lot-->
   primitiveCone()
   texture("builtin:uvtest.png")
Lot-->
   primitiveCone(8,10,15 )
   texture("builtin:uvtest.png")
我方已验证示例:primitiveCone(verified_gold)· 点击展开代码 · 在 demo 中运行 →
@StartRule
Lot --> primitiveCone(16, 2, 5) color(0.9, 0.7, 0.4)
insertAlongUV native ✓ cpp-fast ✓ 已验证 10 条 · silver 官方文档 ↗ #
沿 UV 方向重复插入几何 / 资产
签名(2 种重载)
insertAlongUV(uvSet, filePath, height)
insertAlongUV(uvSet, filePath, height, heightDirection, heightAlignment)
参数说明
参数类型说明
uvSetfloatNumber of texture coordinates set (integer number in [0,9]). The numbering corresponds to the texture layers of the material attribute, see also Texturing: Essential knowledge.
filePathstringFile path of the geometry asset to insert. See Asset Search for information about search locations. The remarks about supported asset formats for the insert operation also apply here.
heightfloatThe height of the inserted geometry in the world coordinate system.
官方说明(英文原文)

The insertAlongUV reads a geometry asset (3D model, polygon mesh) from a file and inserts it along the current shape's uv coordinates by mapping the width and depth of the asset to the chosen uv-set. Specifically the following:

  • the x-span of the asset is mapped to u in [0,1] and is repeated,
  • the z-span is mapped to -v,
  • the y-span is set to the chosen height parameter.

The asset is cut and bent to a new geometry that fits into the uv space of the initial shape.

On a shape with a uv-set assigned, use split and texturing operations such as normalizeUV, rotateUV, and scaleUV to setup the uvs according to your needs.

Note:

The asset is only mapped onto triangles and quads of the current shape.

Considerations

  • The new geometry does not inherit the vertex normals of the asset. You can recompute vertex normals using setNormals or softenNormals.
  • The asset is cut in order to fit it onto the uv space. This creates coplanar edges and collinear vertices which can be removed using cleanupGeometry.
  • Unlike the insert operation, the creation of a new geometry breaks instancing. Furthermore, trimming is not applied automatically.
官方示例(共 7 个,展示前 3 个) · 点击展开
const width  = assetInfo("barrier.obj", sx)
const height = assetInfo("barrier.obj", sy)

Street --> split(v, unitSpace, 0) {
               width : InsertBarrier |
               ~1    : Street.       |
               width : InsertBarrier |
               ~1    : Street.       |
               width : InsertBarrier }

InsertBarrier -->
    rotateUV(0, 90)
    normalizeUV(0, u, collectiveAllFaces)
    insertAlongUV(0, "barrier.obj", height)
const width = assetInfo("barrier.obj", sz)
	           
InsertBarrier -->
    normalizeUV(0, u, collectiveAllFaces)
    insertAlongUV(0, "barrier.obj", height)
const width  = assetInfo("guardrail.obj", sx)
const height = assetInfo("guardrail.obj", sy)
const depth  = assetInfo("guardrail.obj", sz)

Street -->
    alignScopeToAxes(y)
    split(v, unitSpace, 0) { depth : rotateUV(0, 180)
                                     InsertGuardrail
                           |    ~1 : NIL
                           | depth : InsertGuardrail }

InsertGuardrail -->
    normalizeUV(0, v, collectiveAllFaces)
    tileUV(0, ~width, 0)
    insertAlongUV(0, "guardrail.obj", height)
我方已验证示例:learning case #78(verified_silver)· 点击展开代码 · 示例过大,请复制源码到 demo 运行
/**
 * File:    Fence_On_Graph.cga
 * Created: 18 Nov 2015 17:11:40 GMT
 * Author:  Esri R&D Center Zurich
 */

/*

Input shape:  street shape (shape with UVs), street width >= base_depth

Fences are created along the u direction of the street shape.

Notes on Occlusion:

* Occlusion Labels:  The fence parts (post, middle, base post, base middle, upper post, upper middle)
  are each labeled with the given occlusionLabel.  These labeled parts are meant to be occluders which
  can be found when te…
footprint native ✓ cpp-fast ✓ 已验证 11 条 · silver 官方文档 ↗ #
按基底参数生成建筑 footprint
签名(1 种重载)
footprint()
官方说明(英文原文)

The footprint operation creates a 2D geometry that is the orthogonal projection of the current shape's geometry onto the plane scope.y=0.

官方示例 · 点击展开
Example -->
    i("building.obj")
    ShowAsset.
    Footprint(scope.sy)
 	
Footprint(height) -->
    footprint()
    extrude(height)
    set(material.opacity, 0.25)
我方已验证示例:learning case #125(verified_silver)· 点击展开代码 · 在 demo 中运行 →
/* footprint operation example */
Lot -->
  extrude(10)
  footprint()
  color("#ffff00")