Menu

on-top operator

Neon22
2008-12-30
2013-05-28
  • Neon22

    Neon22 - 2008-12-30

    Here is an example of a script (modified from subblue on flickr)
    that could be turned into a city if we had a way to put objects attached to existing ones in some simple way.
    (Greeble is the jargon term for this kind of random city building detail)
    (an example using xml style construction rules is called citygen from 2005 is here: http://www.cs.tau.ac.il/~tommer/citygen/ )

    Of course it may be possible to do this in the grammar also..?  But seems much harder..  Any suggestions anyone ?

    // Initial position
    set background #FFF
    { x -4 y -4 z -0.5 s 1 1 0.1 z 0.5 color #0099FF }
    mat
    // Ground plane
    { x -0 y -0  z -0.5  s 10 10 0.01 color #000  }  box

    // make 6x6 blocks
    rule mat {
    6  * { x 1 hue 20 } 6  * { y 1 hue 20 } split
    }

    // do a z -0.5 to center cube around zero before doing scale
    //  - then translate back with z 0.5 at end of operation
    // this way all bases line up.

    // X-split
    rule split w 5 maxdepth 4 > square {
    { z -0.5   s 1/3 1 1.3  x -1    hue 5    z 0.5 } split
    { z -0.5   s 2/3 1 0.7  x 1/4  hue 30  z 0.5 } split
    }

    // Y-split
    rule split w 5 maxdepth 4 > square {
    { z -0.5   s 1 1/3 0.8  y -1    hue 10   z 0.5 } split
    { z -0.5   s 1 2/3 1.2  y 1/4  hue 20   z 0.5 } split
    }

    // No split
    rule split w 0.3 {  square }

    rule square {
    { z -0.5 s 0.95 0.95 0.8 z 0.5 }  box
    // now we have a city (although shows diagonal preference for early choices)
    // now we want to add a box on top of the just drawn box.
    // a kind of 'ontop' operator that will place the next item on top of the bounding box just drawn
    { z -0.5 s 0.4 0.4 0.5     z 0.9 } sphere
    // or perhaps a way to ask the just drawn box what its actual dimension was and
    //   to set absolute values instead of relative ??
    // perhaps we could store in a variable and then extract values
    // e.g.
    // block = { z -0.5 s 0.95 0.95 0.8 z 0.5 }  box
    // { z -0.5  s 0.4 0.4 0.5  z 0.5 setz block.zmax } sphere
    }

     
    • Mikael Hvidtfeldt Christensen

      Hi,

      not sure I understand - but it is not hard to place a box above the one just drawn in your example: just make a composite object containing both the box and the box above it. In the same reference frame, it is easy to position objects relative to each other. For you example this would be:

      rule square {
      { z -0.5 s 0.95 0.95 0.8 z 0.5 }  onTopBox
      }

      rule onTopBox {
            box 
            { z 1 h 180 } box // this box is placed on top?
      }

       
    • Neon22

      Neon22 - 2008-12-31

      Thanks - yes kind of obvious really... :)

      How about if i only want to run a rule if another rule has run.
      This would be a context sensitive grammar. I see from the blog you are looking into these.
      Are you considering extending the system to also allow context sensitivity in rule selection ?

      I have posted a new city maker in the flickr section

       
    • Neon22

      Neon22 - 2008-12-31

      Thanks Mikael,
      yeah working on getting sunflow and luxrender organised on my system.
      You can see the long tall thin 'buildings' which I would like to control better so that another rule gets called if they occur. This would help to eliminate these 'wrong' looking buildings.

      But I suspect the proper solution is to reformulate my rules to subdivide more first.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.