Cubic Rings - nearly perfect rings from iterations of cubes

Share your ZGE-development tips and techniques here!

Moderator: Moderators

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

Cubic Rings - nearly perfect rings from iterations of cubes

Post by jph_wacheski »

Sorta' stumbled onto this one, while modeling some procedural creatures,. it is a simple way to create rings.

Seems nice and fast, for my uses anyhow. If you change the cube to a sprite you can do some cool ring-burst particle type effects quite simply as well,. . transladed primitives seem to be an ideal building block for more complex structures on these modern graphics cards,.

Perhaps a basic MeshTorus would be usefull. I know there is one in the implicit stuff,. however the layout of the points is so strange,. I do think that area holds much promise,. . I was creating strange shapes from trig. but I still don't quite understand what I'm doing. :S
Attachments
jphs__rings_example.zgeproj
just look in the file to figure it,. .
(2.16 KiB) Downloaded 924 times
looks like this.
looks like this.
rings.jpg (68.96 KiB) Viewed 14372 times
iterationGAMES.com
User avatar
VilleK
Site Admin
Posts: 2274
Joined: Mon Jan 15, 2007 4:50 pm
Location: Stockholm, Sweden
Contact:

Post by VilleK »

That's nice, it does seem to perform well thanks to using simple cubes.

Yeah the implicit stuff seemed to hold much promise, but after doing the 3ds-import function I've sort of abandoned it. It seems much simpler to just export a few models (including primitives such as cone and torus) from 3ds and import them and warp them with a meshexpression, compared with trying to make clever implicit expressions which is difficult.

Also the implicit polygonizer use the very simplest algorithm available (marching cubes). There are many other approaches that generate nice well-formed triangles, but they are much more advanced and require more time for research and implementation as well as runtime code size (additionally potentially protected by software patents). This is an area that is certainly worth revisiting later though, maybe forum members can help with information.
User avatar
rrTea
Posts: 475
Joined: Sat Feb 15, 2014 9:54 am

Re: Cubic Rings - nearly perfect rings from iterations of cubes

Post by rrTea »

Here is something similar but a bit more dynamic (it changes the number of meshes according to the radius)! It's pasted directly from a project so it has a few eccentricities - for example (generally speaking) the individual building blocks should get slightly wider as the radius of the circle grows (here they're shrinking), but in my project I wanted to show a particular thing so I made it like this... etc. Anyway - move the mouse up/down to adjust the circle!

Code: Select all

<?xml version="1.0" encoding="iso-8859-1" ?>
<ZApplication Name="App" Caption="ZGameEditor application" Camera="cam_Ortho" FileVersion="2">
  <OnLoaded>
    <Variable Name="DeathEdge"/>
    <Variable Name="Pi2"/>
    <ZExpression Expression="Pi2=PI*2;"/>
  </OnLoaded>
  <OnUpdate>
    <ZExpression>
      <Expression>
<![CDATA[DeathEdge = clamp(abs(App.MousePosition.Y),0.06,1)*12;

transf_DeathRadius.Translate.Y = DeathEdge;


//
transf_DeathRadius.Scale.X = 0.5 - DeathEdge*0.02;
transf_DeathEdgeSingleStep.Rotate.Z = 1f/(DeathEdge*Pi2);]]>
      </Expression>
    </ZExpression>
  </OnUpdate>
  <OnRender>
    <UseMaterial Material="mat_ColorMondrian"/>
    <Repeat Count="65">
      <OnIteration>
        <RenderTransformGroup Name="transf_DeathRadius" Scale="0.38 1 1" Translate="0 12 0">
          <Children>
            <RenderMesh Mesh="mesh_Triangle"/>
          </Children>
        </RenderTransformGroup>
        <RenderTransform Name="transf_DeathEdgeSingleStep" Rotate="0 0 0.0133"/>
      </OnIteration>
      <WhileExp>
<![CDATA[//this.Iteration=current iteration nr. Return false to end loop.

int i;
i = this.Iteration;

return (i < DeathEdge*Pi2);]]>
      </WhileExp>
    </Repeat>
  </OnRender>
  <Content>
    <Material Name="mat_ColorMondrian" Shading="1" Light="0"/>
    <Camera Name="cam_Ortho" Kind="1" Position="0 0 15" OrthoZoom="12"/>
    <Mesh Name="mesh_Triangle">
      <Producers>
        <MeshBox Grid2DOnly="255"/>
        <MeshTransform Rotation="0 0 -0.125"/>
        <MeshExpression>
          <Expression>
<![CDATA[//V : current vertex
//N : current normal (turn off AutoNormals when modifying normals)
//C : current color (turn on VertexColors)
//TexCoord : current texture coordinate (turn on HasTexCoords)

if (V.Y< 0) V.Y = 0;]]>
          </Expression>
        </MeshExpression>
      </Producers>
    </Mesh>
    <Mesh Name="mesh_Rectangle">
      <Producers>
        <MeshBox Grid2DOnly="255"/>
      </Producers>
    </Mesh>
  </Content>
</ZApplication>
I'm wondering - if I wanted to make a full circle, wouldn't bending RenderNet be better than drawing individual meshes?
Attachments
04.gif
04.gif (483.48 KiB) Viewed 12473 times
Post Reply