Custom parametric meshes

Share your ZGE-development tips and techniques here!

Moderator: Moderators

Post Reply
shviller
Posts: 4
Joined: Tue Nov 10, 2009 4:47 pm

Custom parametric meshes

Post by shviller » Fri Dec 05, 2014 4:05 pm

When you're building procedural models, you often want to abstract away some pieces that make sense on their own (a torus, a spiral, or, in fact, just about anything in this thread).

Kjell shared a neat technique that allows to imitate new "kinds" of parametric mesh producers (such as MeshTorus or MeshSpiral). I did a quick search and it seems it isn't explained anywhere on the forum, so with Kjell's blessing I decided to amend that.

Here's how:

1. Drag and drop some Variable components into your Mesh. You can't just add them right there (BTW, Ville, why is that the case? Kjell's guess is that it's because the graph editor doesn't support it), so you have to declare them somewhere else and then move them.

2. Then from the other mesh you can set the variables using a ZExpression and end with a RefreshContent + MeshLoad, like so:

Code: Select all

TorusThickness = 1;
TorusRadius = 4;

@RefreshContent(Component:TorusMesh);
@MeshLoad(Mesh:TorusMesh);
Here are some examples:
Attachments
parametric_MeshLoad_function.zgeproj
This is the cleaner and safer function-based version, made by Kjell.
(1.24 KiB) Downloaded 216 times
parametric_MeshLoad.zgeproj
TorusMesh is the new parametric producer, WheelMesh and StackingRingsMesh are usage examples. This is the "convert from the traditional approach with minimal effort" version.
(2.73 KiB) Downloaded 277 times

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

Post by VilleK » Sun Dec 07, 2014 1:27 pm

Nice technique, thanks for sharing. Have you built any cool geometry this way? Please post screenshots if you want, it is always fun to see what ZGE is used for.

Post Reply