Beta release 1.9.8b

Information and change log about the latest ZGameEditor release.

Moderator: Moderators

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

Post by VilleK »

Ah, you're right we would need to duplicate any properties on MeshCombine, that's a downside with this approach.
About "subloop", shouldn't we be able to use nested MeshLoop-components instead?
Anyway, I've been to a friends wedding this weekend so I didn't have any time to work on this, but hopefully I can code something during the following days.
kattle87
Posts: 402
Joined: Wed Sep 26, 2007 9:06 am
Location: Italy

Post by kattle87 »

A nested loop mesh is good for doing some work, but for example if you need to make a recursive mesh, you can't do it by nesting meshloops unless you nest infinite of them! Instead, an "easy" use for the nested MeshLoops are for example little branches on some bigger branches. But if you want to add another "sublevel", than you might need another nested loop (EG: leaves made with a meshloop). So you just have to "manually arrange" them, while with recursion everything is faster to write (and more difficult to understand). The trick is just about loading the mesh that will be computed "on request" like I used to do when working on that "fractal tree".

However, recursion is not that much important right now, while the MeshLoop could be nice and be useful.

Hejdå!
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
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Perhaps if we allow MeshLoad to load itself (with some kind of detection to guard against infinite recursion) then recursion can be done with a Condition-component that executes MeshLoad on the condition of a global variable that holds current recursion depth. Ok, but first we need the MeshLoop component, so I'll get working on that.
kattle87
Posts: 402
Joined: Wed Sep 26, 2007 9:06 am
Location: Italy

Post by kattle87 »

Allowing MeshLoop to load himself can do the trick provided some optional details I'm thinking about. The important one to me is getting the counter from from one value to another one, and it stops looping. As I suggested before, if the counter was to go down to zero ("loop until counter > 0") I would like it a bit more maybe, but we need our main user opinion here :D
JPH what do you think about this?
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
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Post by jph_wacheski »

This all sounds interesting,. as you know I prefer to build stuff with the toys you guys provide us,. not so much the mindpain maths.

Idealy any sort of condition should work to terminate the growth of any branch because randomness may be used. say each loop randomly removes some size, or increses it, or rotates it or what have you, and when that branch reaches whatever limit we are lookng for the loop dies., leaving a nice branch structure. However similar structures could be devised if we just have a simple counter as well,. just changes how we build the conditions for the transforms,. so what ever works, will work :)

see here;

Code: Select all

/*
mindtrees
*/

10  * { rx 8 ry 36 } R1
end

rule end {
 { s 7 }  sphere
}

rule R1 w 32 md 64 > end  {
  { x 2 rz -1 ry 2 s 0.99 } R1
  { s 1 }  line
}

rule R1 { 
  { x 1 rz -3 ry -21 s 0.99 } R1
  { x 2 rz 3 rz 45 s 0.99 }  R1 
  { s 2 }  box
} 
this structure synth code "rule R1 w 32 md 64 > end"

creates a rule R1 with a weight (W) of 32 and a max depth (MD) of 64 the '> end' is the leaf part when the rule reaches its lifespan it sprouts,. . intead of having a MD of 64 I could just have some rules with various weights and have one or more that dont re-loop. I supose there are many roads to the same castel,. . but remember, out giraffe is probably in another castel any how,. ;) the fun is on the road!
iterationGAMES.com
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Beta updated today.

So this is an experiment with the new MeshLoop-component.

I took the properties from Repeat-component and added logic to combine and transform vertices.

There is still work to be done but I think it already shows some promise. It's pretty easy to get nice results without having to write expressions.

Example of use:

Code: Select all

ZZDC<?xml version="1.0" encoding="iso-8859-1" ?>
<Mesh Name="Mesh3">
  <Producers>
    <MeshSphere/>
    <MeshTransform Position="-3.96 -1.42 0"/>
    <MeshLoop Scale="0.95 0.95 0.95" Count="32" Position="0 1.85 0" Rotation="0 0.02 0.03">
      <OnIteration>
        <MeshBox/>
      </OnIteration>
    </MeshLoop>
    <MeshCombine/>
    <MeshLoop Scale="0.95 0.95 0.95" Count="21" Position="0 -1.85 0" Rotation="0 0.02 0.03">
      <OnIteration>
        <MeshBox/>
      </OnIteration>
    </MeshLoop>
    <MeshCombine/>
  </Producers>
</Mesh>
Attachments
two loops with boxes plus combine with transformed sphere
two loops with boxes plus combine with transformed sphere
boxloop.jpg (62.44 KiB) Viewed 31993 times
loop with MeshLoad of imported mesh
loop with MeshLoad of imported mesh
bartloop.jpg (71.28 KiB) Viewed 31993 times
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

SWEET!

Post by jph_wacheski »

Super cool Ville, this is very nice and looks to be quite powerfull,. it is easy to build with in the editor and gives instant feedback,. yup I likes it!

I notice one problem when using a sphere for the mesh,. when I was changeing the sphere samples settings the mesh goes wanky,. it looses iterations and joins the mesh in wrong ways,. here try this;

Code: Select all

ZZDC<?xml version="1.0" encoding="iso-8859-1" ?>
<Mesh Name="Mesh1">
  <Producers>
    <MeshLoop Name="ctrl2" Count="5" Position="0 -1.08 0" Rotation="0 0 0.2">
      <OnIteration>
        <MeshLoop Name="ctrl" Scale="0.9 0.9 0.9" Count="21" Position="0.75 0.75 0.75" Rotation="0 0 0.1201">
          <OnIteration>
            <MeshSphere ZSamples="21" RadialSamples="31"/>
            <ZExpression Expression="ctrl.rotation.z=noise2(ctrl.iteration*.02,ctrl2.iteration*.05);"/>
          </OnIteration>
        </MeshLoop>
      </OnIteration>
    </MeshLoop>
  </Producers>
</Mesh>
increase the sphere radial samples and watch the structure eat itself! I hope that is a small bug as this is a very fine component with a great many uses to be sure.
iterationGAMES.com
kattle87
Posts: 402
Joined: Wed Sep 26, 2007 9:06 am
Location: Italy

Post by kattle87 »

Not sure but maybe this is some kind of too-many-vertexes mesh bug =)
Howeve, nice creation!
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
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Ah, you're right Kattle, it reaches the 65k vertex limit. The maximum number of vertices in a single mesh is currently 65536. This is because this consumes less runtime memory (video memory and main memory) and possibly renders more quickly because more vertices fits in cache. But if we're starting to create large meshes we could easily increase this limit to using 32-bit vertex indices instead which would solve the problem. Meanwhile I'm adding a log-message if the limit is exceeded.
kattle87
Posts: 402
Joined: Wed Sep 26, 2007 9:06 am
Location: Italy

Post by kattle87 »

BTW: The good: my Laptop got fixed... If this weekend I'm having some free time I'll look into new mesh possible combines.
The bad: I won't have that much time because of university studying (and real life going on with friends on the seaside ;))
The ugly: I know nothing about how meshes are stored, so I will have to study a little about how they work, but it looks (almost) easy.
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
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Post by jph_wacheski »

What!,. there are limits?

ok, good to know.., (perhaps we could also add a note in the mesh section of the docs) although I have found going above that limit is apparently possible, and only sometimes leads to strangnesses,. . would doing this possible cause random problems, or if it works here, it will work for the rest of you? just curious, as this type of mesh building does make it tempting to do crazy complex meshs,. I will have to do some testing for actual game models to keep an eye on performance levels,. I am having some fun with this, cheers!
iterationGAMES.com
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

I just removed that limit :) . Changing the index datatype to 32 bit did not degrade performance on my system or add to code size, so we might as well try it and see if anyone runs into problems. Beta updated.
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

Beta updated. Some more experimentation:

New property on MeshLoop: RecursionCount. When this value is larger than zero and the loop is on the last iteration, instead of running the OnIteration-producers, it will reload the whole mesh. This is useful for making iterative tree branches. The mesh itself has a new property: CurrentRecursion that can be used in expression to examine the current recursion depth (maybe reducing tri-count as mesh grew smaller, or set colors based on depth).

Another improvement is in the array editing dialog: I couldn't get copy/paste of cells/rows selections to work so instead there are now two new buttons that allows you to copy the whole array (or in 3d-arrays the current 2d-view) as comma-separated text. So paste it into your text-editor, arrange the values as needed (copy lines etc), then paste it back into the array editor.

I expanded on jph's example to use recursion:

Code: Select all

ZZDC<?xml version="1.0" encoding="iso-8859-1" ?>
<Mesh Name="Mesh4">
  <Producers>
    <MeshLoop Name="ctrl2" Count="4" Position="0 -1.08 0" Rotation="0 0 0.2">
      <OnIteration>
        <MeshLoop Name="ctrl" Scale="0.9 0.9 0.9" Count="6" RecursionCount="3" Position="0.6626 0.74 1.2255" Rotation="0 0 0.0465">
          <OnIteration>
            <MeshSphere ZSamples="7" RadialSamples="8"/>
            <ZExpression>
              <Expression>
<![CDATA[ctrl.rotation.z=noise2(ctrl.iteration*.02,ctrl2.iteration*.05)*0.15 + rnd()*0.05;
ctrl.position.z=random(0.75,0.5);]]>
              </Expression>
            </ZExpression>
            <MeshExpression AutoNormals="0" VertexColors="255">
              <Expression>
<![CDATA[//V : current vertex
//N : current normal (turn off AutoNormals when modifying normals)
//C : current color (turn on VertexColors)

this.C.B=Mesh4.CurrentRecursion * 0.2;]]>
              </Expression>
            </MeshExpression>
          </OnIteration>
        </MeshLoop>
      </OnIteration>
    </MeshLoop>
  </Producers>
</Mesh>
This is the source of the other image:

Code: Select all

ZZDC<?xml version="1.0" encoding="iso-8859-1" ?>
<Mesh Name="Mesh3">
  <Producers>
    <MeshSphere/>
    <MeshTransform Position="-3.96 -1.42 0"/>
    <MeshLoop Scale="0.95 0.95 0.95" Count="32" RecursionCount="1" Position="0 1.85 0" Rotation="0 0.02 0.03">
      <OnIteration>
        <MeshBox/>
      </OnIteration>
    </MeshLoop>
    <MeshCombine/>
    <MeshLoop Scale="0.95 0.95 0.95" Count="21" RecursionCount="1" Position="0 -1.85 0" Rotation="0 0.02 0.03">
      <OnIteration>
        <MeshBox/>
      </OnIteration>
    </MeshLoop>
    <MeshCombine/>
  </Producers>
</Mesh>
Attachments
bend_with_ball.jpg
bend_with_ball.jpg (18.13 KiB) Viewed 31900 times
jph_tree_loop.jpg
jph_tree_loop.jpg (46.94 KiB) Viewed 31900 times
User avatar
jph_wacheski
Posts: 1005
Joined: Sat Feb 16, 2008 8:10 pm
Location: Canada
Contact:

Post by jph_wacheski »

Very fine additions!

I can now get back to composing some chip-tune style beats,. hand copying patterns got too tiering,. this is great! I had almost forgotten how cool the synth system sounds with tight little beats playing,. roc!

The recursion buisness it amazing! many uses and a simple to work implementation,. . ZGE is getting a lot more interesting with these new mesh building techniques, from a generative art angle anyhow. the new art will no doubt lead to many interesting creations both games and demos. huge thanks again for your efforts!
iterationGAMES.com
kattle87
Posts: 402
Joined: Wed Sep 26, 2007 9:06 am
Location: Italy

Post by kattle87 »

really smart solution Ville! An amazing job, really :D I love this! I guess most of the work here is done, now we need testing :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