CityEngine_Tutorials&Example(2011-2014)

CityEngine_2011_Tutorials
CityEngine_2011_Examples
CityEngine_2012_Examples
CityEngine_2012_Tutorials
CityEngine_2013_Examples
CityEngine_2013_Tutorials
CityEngine_2014_Examples
CityEngine_2014_Tutorials

 


 

imageBestRatio


Synopsis

string imageBestRatio(string searchQuery, string axisSelector)

Parameters

  • searchQuery
    Search query to apply on list of all files in the workspace. See fileSearch for details about the syntax.
  • axisSelector (keyword)
    Selector which defines which scope axes ratio is used as a reference. Valid values are (xy | xz | yx | yz | zx | zy).

Returns

Returns texture with best ratio match (according to axisSelector).

This function returns the texture with the best ratio match, from the list specified in searchQuery, according to the specified combination of axes.

Note: In case multiple files share the best ratio, a random file is returned among those

Examples

Setting up texturing based on the best pixel ratio

The goal is to set up the texturing, depending on the best pixel ratio of the list of desired textures. The following textures all have different resolutions.

CGA example:
Lot --> s('.9,'.9,'.9) center(xz) recursiveSplit(0)
recursiveSplit(n) -->
	case scope.sx >= 1.5 && scope.sz >= 1.5:
		split(x){~scope.sx/3: split(z){~scope.sz/3: recursiveSplit(n+1)}*}*
	else: doTexturing
doTexturing -->
	set(material.colormap, imageBestRatio("/myProject/assets/textures/*.jpg", "xz"))
	setupProjection(0, scope.xz, scope.sx, -scope.sz)
	projectUV(0)

Copyright ?2008-2015 Esri R&D Center Zurich. All rights reserved.

 

 

 

 

 


 

imageApproxRatio


Synopsis

string imageApproxRatio(string searchQuery, string axisSelector, float n)

Parameters

  • searchQuery
    Search query to apply on list of all files in the workspace. See fileSearch for details about the syntax.
  • axisSelector (keyword)
    Selector which defines which scope axes ratio is used as a reference. Valid values are (xy | xz | yx | yz | zx | zy).
  • n
    Number (integer >= 1) of textures to consider (one is randomly picked out of the n best textures).

Returns

Texture with one of the n best ratio matches (according to axisSelector).

This function returns one of the n textures with the best ratio match, from the file list specified insearchQuery, according to the specified combination of axes.

Note: imageApproxRatio(path, axisSelector, 1) = imageBestRatio(path, axisSelector)

Examples

Setting up texturing based on the best pixel ratio

The goal is to set up the texturing, depending on the best pixel ratio of the list of desired textures. The following textures all have different resolutions.

CGA example:

Note: Note the color variations in the next two images by using only the “best ratio” (n = 1) and “choose randomly one of the best three ratios” (n = 3).

n = 1:
Lot --> s('.9,'.9,'.9) center(xz) recursiveSplit(0)
recursiveSplit(n) -->
	case scope.sx >= 1.5 && scope.sz >= 1.5:
		split(x){~scope.sx/3: split(z){~scope.sz/3: recursiveSplit(n+1)}*}*
	else: doTexturing
doTexturing -->
	set(material.colormap, imageApproxRatio("/myProject/assets/textures/*.jpg", "xz",1))
	setupProjection(0, scope.xz, scope.sx, -scope.sz)
	projectUV(0)

n = 3:
..
	set(material.colormap, imageApproxRatio("/myProject/assets/textures/*.jpg", "xz", 3))
..

 

 

 

 

 


 

fileRandom


Synopsis

string fileRandom(string searchQuery)

Parameters

  • searchQuery
    Search query to apply on list of all files in the workspace. See fileSearch for details about the syntax.

Returns

returns random file from list specified in searchQuery.

This function returns a random file from the list specified in searchQuery.

Examples

	fileRandom("assets/*.obj")
	# result = any one obj file from the assets dir

 

 

 

 

 


 

fileBasename


Synopsis

string fileBasename(string path)

Returns

returns file base name of given path, without directory prefix and file extension.

This function returns the file base name (without the directories or extension) of the given path.

Examples

	fileBasename("assets/obj/mygeometry.01.obj")
	# result = "mygeometry.01"

 

 

 

 

 


 

assetFitSize


Synopsis

string assetFitSize(string searchQuery, string axisSelector, float maxScaleError)

Parameters

  • searchQuery
    Search query to apply on list of all files in the workspace. See fileSearch for details about the syntax.
  • axisSelector
    Selector of axes for the currect scope. Supported values are: “x”,“y”,“z”,“xy”,“xz”,“yz”,“xyz”
  • maxScaleError
    Float value to control file selection. If it is 0 all input files are returned, sorted depending on their size. If the value is > 0, only a subset of the input files is returned: 0.1 means that maximum +-10% scaling is allowed.

Returns

Random asset (according to axisSelector) which is in the maxScaleError range.

This function returns one of the assets in the maxScaleError range, from the file list specified in searchQuery, according to the specified axisSelector.

Examples

	assetFitSize("assets/*.obj","xz",0.2)
	# result = "assets/chosenAsset.obj"

assetBestSize


Synopsis

string assetBestSize(string searchQuery, string axisSelector)

Parameters

  • searchQuery
    Search query to apply on list of all files in the workspace. See fileSearch for details about the syntax.
  • axisSelector
    Selector of axes for the currect scope. Supported values are: “x”,“y”,“z”,“xy”,“xz”,“yz”,“xyz”

Returns

Asset with the best size fit (according to axisSelector).

This function returns the asset with the best fitting size, from the file list specified in searchQuery, according to the specified axisSelector.

Examples

Inserting assets based on their (physical) size

The goal is to insert assets from a pool, depending on their (physical) size. The pool of assets is seen in the following image. Colors are (only) used to visually emphasize the size ratio.

Lot -->
	s('.9,'.9,'.9) center(xz) recursiveSplit(0)
recursiveSplit(n) -->
	case scope.sx >= 1.5 && scope.sz >= 1.5:
		split(x){~scope.sx/3: split(z){~scope.sz/3: recursiveSplit(n+1)}*}*
	else: doInsert
doInsert -->
	innerRect
	alignScopeToAxes(y)
	i(assetBestSize("/myProject/assets/cube_*.obj","xz"))

Note: Note that small parts get blue assets while large parts get red assets.