Hi,
sure ! 🙂
here's the example : http://resources.arcgis.com/en/communities/city-engine/01w90000000r000000.htm#s=0&n=30&d=1&md=cte-ce...
download the 'Example Instance City 2012'.
i() inserts an asset in the current scope. basically that way, you create instances of assets in CityEngine. this example shows how instead of modeling all buildings procedurally, you can also use premodeled buildings and insert them according to their best-fitting ratio or size in the scope of a shape.
the same methodology is used to e.g. distribute trees on point marker shapes.
maybe start with the following code on 1 shape :
( copy 1 obj file in the assets folder .. )
buildingAsset = "assets/skyscraper_1.obj"
Lot -->
alignScopeToAxes(y)
s(0,0,0)
i(buildingAsset)
Building.
let me know if there's more questions, ok ?
have fun !
Matt
That worked like a charm, thank you so much! The i() is really handy. I adapted that code to work for 6 different buildings by adding this line.attr buildingAsset = assetApproxSize("*/assets/*.obj", "xz", 6)
Lot -->
alignScopeToAxes(y)
s(0,0,0)
i(buildingAsset)
Building
Now it does populate the 6 building options I just have to figure out how to make them properly fit into the lots and align themselves so it doesn't look so messy. The Instance City example cga file had quite a few errors and I couldn't get it to run so I can't quite figure out how they solved that issue. Since I'm new to cga I can't even tell whats valid or not with their code. I'm just guessing but I think it had something to do with alignScopeToGeometry and alignScopeToAxes not sure how though.Instance City Code below:/**
* File: instance_city_on_ground.cga
* Created: 5 May 2010 09:21:09 GMT
* Author: andi
*/
version "2011.1"
# select one of the best 3 fitting building asset
attr scifiasset = assetApproxSize("*/assets/scifi_building_*.obj", "xz", 3)
# RULES ###########
###################################
# Buildings
#
@StartRule
Lot -->
Ground
convexify comp(f){all : alignScopeToGeometry(yUp,0,longest) innerRect Footprint }
LotCorner --> Ground
LotInner --> Lot
Footprint -->
alignScopeToAxes(y)
Building
Building -->
i(scifiasset)
# specularity
set(material.specular.r,70) # for the looks in the CityEngine we add some over-exagerated specularity (otherwise the model is too dark for opengl...)
set(material.specular.g,70)
set(material.specular.b,70)
set(material.specularmap,"assets/scifi_texture_refl_2k.jpg")
set(material.shininess,20)
# bump
set(material.bumpmap,"assets/scifi_texture_bump_2k.jpg")
set(material.bumpValue, -.1)
# opacity
set(material.opacitymap,"assets/scifi_texture_opacity_2k.jpg")
# reflectivity
set(material.reflectivity, 2.3)
Ground -->
setupProjection(0,world.xz,300,2048) projectUV(0)
texture("scifi_texture_ground.jpg")
# specularity
set(material.specular.r,10) # for the looks in the CityEngine we add some over-exagerated specularity (otherwise the model is too dark for opengl...)
set(material.specular.g,10)
set(material.specular.b,10)
set(material.specularmap,"scifi_texture_ground.jpg")
set(material.shininess,15)
# bump
set(material.bumpmap,"assets/scifi_texture_ground.jpg")
set(material.bumpValue, -.25)
# reflectivity
set(material.reflectivity, 1.2)
###################################
# Streets
#
Street --> StreetTex
Sidewalk --> comp(f) {all: split(y) { 2 : StreetLine | ~1: Ground } }
Crossing --> StreetTex
Junction --> Crossing
JunctionEntry --> Street
StreetTex -->
setupProjection(0.0, scope.xz, 600, 300)
texture("assets/scifi_texture_street_dark.jpg") projectUV(0.0)
# specularity
set(material.specular.r,20) # for the looks in the CityEngine we add some over-exagerated specularity (otherwise the model is too dark for opengl...)
set(material.specular.g,20)
set(material.specular.b,20)
#set(material.specularmap,"assets/scifi_texture_street_dark.jpg")
set(material.shininess,60)
# reflectivity
set(material.reflectivity, .3)
StreetLine -->
setupProjection(0.0, world.xz, 900, 150) texture("scifi_texture_street_bright.jpg") projectUV(0.0)