Multiple CGA Rule Files to a Single City Engine Layer

2367
2
07-18-2016 10:50 AM
JugalPatel
New Contributor II


Hello,

I'm wondering if it is possible to apply two separate cga rule files to the same layer. Specifically, I have a water layer and I am trying to add this rule to it to animate the water:

@Range(-180, 180)

attr Rotation = 0

@Range(0.1, 20.1)

attr Scale = 5

@File

attr Texture = "SeaWater.jpg"

attr SizeX = 100

attr SizeZ = 100

Water -->

  alignScopeToAxes(y)

  rotateScope(0,Rotation,0)

  setupProjection(0, scope.xz, SizeX * Scale, SizeZ * Scale)

  projectUV(0)

  texture(Texture)

  # This line makes it animate in a web scene.

  set(material.name, "watermaterial__waterparams_2_5")

But then I'm also trying to see if I can add another rule to it as well, that will extrude the water, allowing me to build a basic flooding model. Here is the second rule:

attr ELEVATION = 0

@StartRule

Lot --> extrude(ELEVATION)

If it is not possible to apply both rules separately, does anyone know how I can combine the two into one rule so that I can apply it? Thanks!

0 Kudos
2 Replies
DevinLavigne
Occasional Contributor III

You can import rules in any CGA rule. So in your example you could create a master CGA rule importing your two CGA files....

// import texture & animate rule

import a1 : "animate.cga"

//import water extrusion

import w1 : "water.cga"

then you could call rules from each file using something like w1.Lot-->...

For more info search CityEngine help for Import

But I don't think your CGA is that complicated and using multiple rules seems unnecessary. Can you just do something like this?

//Attributes

@Group("Extrusion")

attr ELEVATION = 0

@Group("Texture")

@Range(-180, 180)

attr Rotation = 0

@Group("Texture")

@Range(0.1, 20.1)

attr Scale = 5

@Group("Texture")

@File

attr Texture = "SeaWater.jpg"

@Group("Texture")

attr SizeX = 100

@Group("Texture")

attr SizeZ = 100

@StartRule

Lot-->    extrude(ELEVATION)

          Water

Water -->

  alignScopeToAxes(y)

  rotateScope(0,Rotation,0)

  setupProjection(0, scope.xz, SizeX * Scale, SizeZ * Scale)

  projectUV(0)

  texture(Texture)

  # This line makes it animate in a web scene.

  set(material.name, "watermaterial__waterparams_2_5")

If you just need the top to animate you can always split the component and texture the faces individually - i.e. comp(f) {top:Top | side: Sides}

0 Kudos
BrianOevermann
Occasional Contributor III

We are just barely getting started with CityEngine so this comment may come from a position of naivete or ignorance, but if you extrude your water data based upon an elevation, wouldn't it simply extrude like a building footprint and not "fill the tub" by expanding to the surface elevation?

It seems like your best method for flood simulation would be to model the flooding with the 3D Analyst extension tools, then import that result into CityEngine.

But again, I may be missing something, so forgive me if I am...

0 Kudos