Structure Synth -cool app,. and possible ZGE features.

All topics about ZGameEditor goes here.

Moderator: Moderators

User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Structure Synth -cool app,. and possible ZGE features.

Post by jph_wacheski »

found a very cool 3D interpitation of Context Free!
Structure Synth is a cross-platform application for generating 3D structures by specifying a design grammar. Even simple systems may generate surprising and complex structures. The design grammar approach was originally devised by Chris Coyne (for a 2D implementation see the popular Context Free Art).
http://structuresynth.sourceforge.net/index.php

We had a start on this type of model generation with kattle87's Fractal Tree here;

viewtopic.php?t=360

Just wondering if anyone (once their exams are all aced!) would like to pick up on this again and possibly expand it more along these lines,. not neciserily with a 'design gramer', although that is very cool,. I am just thinking of a nice generalised set up (scripts, library?) to help people build models using this sort of iterative technique.

I have been hacking around with some of these ideas but more for realtime animated objects however I would very much use it for static objects as well, if we can work out a simple method to work with,. .

anyway the app. is quite fun to play with too! makes me want to do some raytraces,. .
iterationGAMES.com
User avatar
Kjell
Posts: 1929
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

:?

ZGE already has a "design grammar" of it's own .. it's called "Scripts" :roll:

For static meshes just use a Repeat Component inside your mesh with a MeshCombine at the end of each loop. The so called "rules" of Structure Synth are identical to the Condition Component or If-Statements in ZExpressions. Of course you cannot use the RenderTransform components like you would when generating / rendering iterative structures in real-time, so use the Matrix library I posted to do those calculations manually.

+ Attached is a basic example of a static mesh without the use of any libraries.

K
Attachments
Mesh.zgeproj
(1.81 KiB) Downloaded 723 times
User avatar
VilleK
Site Admin
Posts: 2382
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Nice example Kjell! You are right that these kind of of meshes can already be made with ZGE but it certainly is a bit more involved than using that specialized tool.

I agree it would be cool if we could make a iterative-toolset sample project for ZGE that makes it easy to fiddle around with parameters to get nice results. Or perhaps it should be a tutorial instead. Jph, if you try to convert any of the grammar-projects to zge and run into problems then post it here so we can figure out if it can be solved with a library or new zge-features.
User avatar
VilleK
Site Admin
Posts: 2382
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

I've looked at your example some more Kjell. It has interesting little details, such as the way you reset the matrix to allow all the "plants" to grow from inside a single loop. I'm impressed! Then I started thinking on how to make it simpler for those of us that are not as comfortable as you with using matrix-operations.

How about we add a MeshTransform-component that performs scale/rotate/translate on an incoming mesh? It's simple to implement and then these kind of iterative meshes require less code. And I think it's general enough to allow other uses so it is a good candidate to become a component.
kattle87
Posts: 402
Joined: Wed Sep 26, 2007 9:06 am
Location: Italy

Post by kattle87 »

this is exactly what I wanted to code. But Sorry guys I might be off until late September. Completely off, since just today I didn't passed an exam so ouch! There are matrix operations already in the math library, this could be really REALLY easy to be done.
In the fall of 1972 President Nixon announced that the rate of increase of inflation was decreasing. This was the first time a sitting president used the third derivative to advance his case for reelection.
-=Hugo Rossi=-
User avatar
Kjell
Posts: 1929
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hej Ville,

Doesn't OpenGL push / pop / reset Matrices pretty much like that? :wink:

A MeshTransform Component would probably be useful yes ( primarily for the rotations obviously ), but you still probably need to increment the values yourself though .. I mean, that component wouldn't keep track of a internal matrix or anything right? You could go the other way around I guess ( transform the existing vertices ), although that would be confusing and leave you with a strangely oriented mesh :P

I'd love to see a Matrix type ( Array? ) and the Dot / Cross / Inverse etc. operations build-in though, so you can use those kind of calculations for not just Meshes.

K
User avatar
VilleK
Site Admin
Posts: 2382
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Sorry about the exam Kattle!

Kjell, you are right, I did not think about that. I simply figured a simple component that has the same properties as RenderTransform and multiplied the vertices would to the trick, but of course in the render-sequence it is OpenGL that is maintaining a matrix for you and accumulate the transformations. So rewriting your example using such a component would still require lots of code to set the correct properties of the MeshTransform.

Unless, as you suggest, the MeshTransform maintains a internal matrix. With a extra property "ResetMatrix" that you can set from expression in the first loop iteration and whenever you want. Perhaps I'll try that and see how it works. Let me know if you see a problem with that approach.
User avatar
Kjell
Posts: 1929
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Well,

For my basic example .. pushing the matrix automatically, and having the option to reset it would be enough. But as you know .. looking at what ZGE does using the OpenGL stack, you often want a little more flexibility then that ( for example being able to pop as well ).

It's a tricky situation, the way Structure Synth is doing it is simple to understand, but it's limiting at the same time.

K
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Post by jph_wacheski »

Nice one Kjell! I had a look at it, and found it a bit confusing at first but I am figuring out what you are doing,. I will see what I can come up useing this method,. and then try to write a little tutorial on how I am useing it. thanks.

As far as a design grammar, yes perhaps it is just a pretentious name for a basic scripting engine,. however I do think there is a difference with Context Free or Structure Synth and a straight scripting/programing implementation,. the simple, design versions are focussed and use a nice cryptic little syntex that is, once learned, very fast to write and work/experiment with,. perhaps I just like that I have to type less,. :P

Code: Select all

9 * { rz 40 x 1 } R1

rule R1 w 1 { 
  {  x 1  z 0.1 rz 30 rx 10 s 0.97} R1
  galac
}

rule R1 w 3 { 
  {  x 1  z -0.3 rz -30 ry 10 s 0.97} R1
  galac
}

rule galac maxdepth 9	{  
  {x 3 rz 20  h 40} galac
  dot
}
perhaps if we get strings in ZGE we can adapt this setup to read simple cryptic "digital design DNA code structures" lol.

Ville- yeah, perhaps a component that accumulates translation/rotation/scale values with a reset hook could work here,. I look forward to trying any experiments you release,. I will see how far I can get with this method too,. . this stuff is fun to play with and fits well with ZGE,. I can also use it to generate complex structures for game objects with little kb added size.
iterationGAMES.com
User avatar
Kjell
Posts: 1929
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hi jph,

Of course the syntax is focussed, its only purpose is to generate meshes iteratively, so the language can be tailored to do just that .. and nothing more. However, if it wheren't for some fundamental limitations in ZGE ( quite a few components don't have a scripted equivalent, nor can you "execute" Component trees from a Script ), you could port the syntax almost 1-on-1 fairly easily.

The rule and weight concept could be mimicked using a grabbel function + switch ( or a bunch of if-statements in the case of ZGE ), and the transformation operations could be global variables that are processed each iteration;

Code: Select all

R1[0] = 1;
R1[1] = 3;

int key = grabbel(R1);

switch(key)
{
  case 0: x=1; z= 0.1; rz= 30; rx=10; s=0.97; galac(); // R1 W1
  case 1: x=1; z=-0.3; rz=-30; ry=10; s=0.97; galac(); // R1 W3
}

Code: Select all

const int galac_max = 9;
static int galac_index = 0;

void galac()
{
  if(galac_index < galac_max){x=3; rz=20; h=40;}else return;
  galac_index ++;
}
All-in-all it does end up a little lenghthier then CFDG, but then again .. there's a whole lot more these C-Style dialects ought to do other then just creating specific types of meshes.

K
User avatar
VilleK
Site Admin
Posts: 2382
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Here is the current work-in-progress. Download the latest beta if you want to try it out.
Attachments
Inspired by &amp;quot;BinaryKite&amp;quot; in Structure Synth.
Inspired by &quot;BinaryKite&quot; in Structure Synth.
zgeKite.png (57.1 KiB) Viewed 17966 times
MeshTransform.zgeproj
Zge-source for the image above. Most code is in the innermost repeat-component. Need latest zge-beta for it to work.
(2.58 KiB) Downloaded 927 times
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

sweet!

Post by jph_wacheski »

yup, that seems to be working nicely,. although it seems to need to have these lines in the repeat components' script;

Mt2.Accumulate = this.Iteration!=0;
return this.Iteration<this.Count;


otherwise the accumulation gets out of hand in the editor,. but toggleing that resets it anyway,. here is a random test,. some sorta' roller device;

Code: Select all

ZZDC<?xml version="1.0" encoding="iso-8859-1" ?>
<Mesh Name="Mesh3">
  <Producers>
    <Repeat Count="10">
      <OnIteration>
        <MeshSphere ZSamples="3" RadialSamples="4"/>
        <MeshTransform Name="Mt2" Position="-0.1 0 0" Rotation="-0.14 0 0" Accumulate="1"/>
        <MeshCombine/>
      </OnIteration>
      <WhileExp>
<![CDATA[//this.Iteration=current iteration nr. Return false to end loop.

Mt2.Accumulate = this.Iteration!=0;
return this.Iteration<this.Count;]]>
      </WhileExp>
    </Repeat>
  </Producers>
</Mesh>
I will be away again for a few days,. but looking forward to getting back here to mess with this in more depth,. very cool!
iterationGAMES.com
User avatar
Kjell
Posts: 1929
Joined: Sat Feb 23, 2008 11:15 pm

Post by Kjell »

Hey,

Just had a quick look at the MeshTransform beta component. Seems like that with the accumulate option turned on even manually entered translations are added onto the Matrix ( which means that when you tab through the fields values are added on each field jump )?

Also, there is no ( easy ) way of incorperating the component as it is now in creating solid / closed / continuous meshes, which is usually what you want in real-time environments to keep the polycount manageable ..

K
User avatar
VilleK
Site Admin
Posts: 2382
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

The problem with the Accumulate-property is that there is not much point in setting it in the designer. Instead the proper use for it is the "Accumulate = this.Iteration!=0" technique in while-expressions. So perhaps the accumulate-property should be readonly in the designer.

Still I think the new component shows some promise. I want ZGE to support component-based techniques for generating interesting meshes. I would also like a matrix-type in expressions so that users could choose between scripting or components, but those kind of language enhancements are not within my current knowledge to implement so I need more time to research or help from other developers.

To create continuous meshes we would need a more advanced MeshCombine-component, perhaps with a "Kind"-property to select "AddQuick (like now)/AddMeld/Subtract/Intersect" for CSG-operations. And to reduce polycount there could be a final MeshSimply-step. Such components also require quite a bit of work to implement so they need to be put on a wish-list for future versions, perhaps when Kattle comes back ;)
kattle87
Posts: 402
Joined: Wed Sep 26, 2007 9:06 am
Location: Italy

Post by kattle87 »

BTW: I'm MADDENING :D

I will see if I will have some spare time during the summer
You know I should stop watching at youtube and program something instead :P
In the fall of 1972 President Nixon announced that the rate of increase of inflation was decreasing. This was the first time a sitting president used the third derivative to advance his case for reelection.
-=Hugo Rossi=-
Post Reply