Using Auto Masonry script

3dpoder - 16/06/2009 12:56
[size=5]using auto masonry script[/size]
By Paul sponer.


🖼️

Estamos trabajando para mostrar las imágenes del foro

Adjunto #107764



introduction
Ive always liked castles. When i started doing 3d modeling i used a tool called ray dream designer and the first tutorial i did was making a Castle. It was a wimpy Castle with flat, porly textured Walls, no Windows, etc. One thing that has always bugged me is that Castle wall models tend todo be textured planes, perhaps whitewashed with cornerestones modeled. Real castles have every estone showing, uneven rows and estone sizes, etc. The pure texture versión looks god from a distance, but you cant get close todo them without the sham appearing. It a los hard todo knok out a few blocks, or add Siege damage. Ive always dreamed of building a Castle that would stand up to scrutiny, but the tools at hand were insuficiente. I wasnt going todo build it block by block.

Anyway, y gave up on the dream for a while, moved on todo newer software versións, and eventually switched todo Blender. With the presence of the Python extensión lenguaje my dream resurfaced. If the computer could do the grunt work, then all id have todo do is the overall design and touch up work. Score. I loked around todo se if anyone else had done this already, but i couldnt find anything similar todo what i wanted.

This confused me, it semed like a simple problem todo solver. More than six hundred lines of code later i discovered why it may not have ben as simple as i expected.
What follows is my first major foray into Python scripting and the results. A section on how todo use the script comes first, followed by a short history of the coding, and some things i learned in the process. Im not fully satisfied with the script yet, but it is very usable and i hope Will be useful todo Many of you.
using auto masonry
Let Jump straight into the fun Stuff shall we? If you dont have it, download the current versión of the script and place it in your scripts Path folder (normally. Blender/.blender/scripts). To start the script, open a scripts window and select scripts>>wizards>>auto masonry. You should se something like this.


🖼️

Estamos trabajando para mostrar las imágenes del foro

Adjunto #107765



It the default GUI. If you press make this wall. You should end up with something like in figure2.


🖼️

Estamos trabajando para mostrar las imágenes del foro

Adjunto #107766



If you dont, you may ned todo install Python. If that doesnt work, y may ned todo fix the script. The current incarnation allows you todo make Walls with or without rectangular Windows, dors, and crenellations. The script generates two Mesh objects, a wall and a grout.

All of the buttons and options have explanatory pop-up text, so fel free todo try it without reading this whole tedious section.

If youre not feeling quite that bold, here is an explanation of all the options in the GUI.


🖼️

Estamos trabajando para mostrar las imágenes del foro

Adjunto #107767




The script is rather fast, so you can make very large Walls if you want. I think the wall in figure 3 tok thirty seconds todo generate.

a few techniques
Here are a few tricks ive come up with. I suspect ingenious users Will come up with Many more.


🖼️

Estamos trabajando para mostrar las imágenes del foro

Adjunto #107768





🖼️

Estamos trabajando para mostrar las imágenes del foro

Adjunto #107769





🖼️

Estamos trabajando para mostrar las imágenes del foro

Adjunto #107770



I hope this script allows Many of you todo realice your dreams of realistic castles, brik Walls, roads, textures, towers, and anything else you can do with it. Id be thrilled if youd drop me ha line and let me know what youre using it for. Let me know if you run across any bugs, and ill try todo fix them right away.
writing the script
If you are still reading this, you may be interested in how the script was programed. The code is decently well documented, so fel free todo Jump right in and fiddle around with it. Here a Little background on how i wrote it as well as a few lessons i learned. Some of this is just god programming practice, some is specific todo Blender.

Before i could programa anything i had todo learn Python. In college i tok a computer programming course, and ive done a bit of programming in my spare time, so there was some background todo build on. Essentially, all programming lenguajes are expressions of a lógical progression, and Python is no diferent. I worked th rouge the built in getting started tutorial in Python, wrote a few small applications todo play with features, and got comfortable with the syntax. At this point i started todo ease into Blender Python extensiones. My first Blender script tok a Mesh object and created every posible polygon with the existing vértices. Not todo useful, but rather fun. I a los discovered that you can crash Blender by trying todo make a Mesh object with todo Many Polygons.

At this stage i was a los examining a lot of the scripts included in Blender. Here are the first two things i learned about programming Python extensiones:
lesson 1: do your homework. This is true in every aspect of life, and applies here, todo. All the basic Python tutorialesi did were invaluable in seing how todo structure an eficient script. Looking in the blenderartists.org forums helped a lot todo. If you put the efort into discovering the right bien todo do things, it Will make your job a whole lot easier later on. Learning Python before learning Blender Python really helped todo kep things straight.
lesson 2: document your code. This is one of the big estrés points in computer Science, and it is so helpful. If someone else wants todo use parts of your script, they shouldnt have todo reconstruct what every line of code does. If you put the script down for a month or two, you wont remember what anything does, Trust me. I know it a drag. I know it fels pointless. Por favor, oh, por favor, document your code. When looking for examples, documentation helped me out immensely. Once i had done a few mini-scripts in Blender i started on the wall Maker. As the script progressed from making plain squares of wall todo complex Walls with dors, Windows, and Edge features, y noticed a few other things: lesson 3: programming Python extensiones is not as hard as it sounds. The extensión framework in Blender includes some very advanced tools which makes programing extensiones rather elementary. If you have an idea for a script, and have any confidence at all in your programming skills, give it a shot.
lesson 3 corollary: but it harder than you think. Be prepared for frustrations. Even though it nice, the Python- Blender integration is far from perfecto. The lógical bien of doing things is often (but discouragingly, not always) how it Will work. Be prepared todo persevere th rouge the tough spots. While working on the script i had thre other Windows open.

The Python scripting reference (accesible from inside Blender in the help menú), the Python Package help menú, and the blenderartists.org scripting forum. These thre, with Lots of persistence, should guide you th rouge your seasons of scripting woes. As the script progressed from simple todo complex, y found myself discovering that my original architecture was insuficiente or highly ineficient for what i was trying todo do. I think i re-wrote every function at least once from the Ground up. Initially i was using the bevel center script todo do the beveling, but i had todo re-code parts of it todo make it work from an outside call (which would require downloading an altered versión of bevel center along with auto masonry) and it was very Slow. In the end i bit the bullet and re-coded my basic block function todo include beveling. At the beginning of the Project i had a free form approach, which i abandonar After working a few days on it. Here the fourth lesson:
lesson 4: be willing todo re-think your approach. Even if it means starting over. Every so often step bak and say todo yourself, does it make sense todo do it this way, or is there a better way? If you want a god script, always opt for the better way. Sometimes it wont do quite what you had in mind, but that better than it not doing anything at all.

I still have Lots of features in mind for future development. Im a los Thinking that i Will have todo re-write a lot of the structure when i get bak todo the Project (in line with lesson 4). However, once the script was mostly finished, it was time for:
the GUI. writing the GUI can be the most fun or most heartbreaquíng part of the process, depending on how well you have managed your variables. If you have nicely written functions and variable management, the GUI should be pretty straightforward. Writing a GUI in Blender is pretty easy, and really finishes of the script. On the other hand, dont fel compelled todo include every característica in the GUI if it isnt well supported, or reliable. There are several features in auto masonry which are almost functional in the code, but not in the GUI. If your code is well documented then code-heads Will be able todo use these features anyhow, and not including them in the GUI helps reduce headaches for entry-level users.

Future improvements

Id like todo improve this script in several directions. Unfortunately, my time is absorbed with other projects right now. Here are a few of the things id like todo add. If you have ideas for other features por favor let me know:
arches: right now Windows and dors are flat topped. Id like todo add both round and pointed arches. This Will require significant re-coding of the basic architecture of the script, but i think it Will be worth it.
flaws: not all estones are perfecto. Some estones should have missing corners, or Even cracks. An early versión (while using bevel center) was able todo knok of corners, but i havent added that característica since converting todo an internal beveling Scheme. Adding cracks would be Even more dificult, but im sure it is posible.
Grout:
right now the grout is Simply a second set of blocks behind the estones. On curved surfaces this creates problems with the grout, which subsurfing helps, but doesnt fix.

A true estone grouting algorithm would a los require a major overhaul of the code, but would a los create a much better finished product, and would allow beveled grout.
more robust window and dor placement: right now the GUI for the window and dor placement is rather limited. The script itself can accept any configuration of window and dor placement, but i couldnt figure out how todo Simply implement the user interfaz. If there is a god bien of doing this, Will someone let me know?
persistent settings: the ability todo save settings todo a file would make it easier todo tweak settings. It would a los allow the creation of múltiple Walls with offset Edges that Will Mesh with one-another, or angled corners with interlocking Edges. Unfortunately, this would a los require a similar code overhaul.

So básically, when i am feeling up to another few weks of programming, ill rewrite the script todo be better than ever. When i do, y Will try todo include any característica requests i receive in the meantime. Alternativaly, if someone else is feeling bold, y encourage you todo make changes todo the script yourself. Id be happy todo learn of all the improvements that can be made, and im sure there are Many.

I hope this script allows Many of you todo realice your dreams of realistic castles, brik Walls, roads, textures, towers, and anything else you can do with it. Id be thrilled if youd drop me ha line and let me know what youre using it for. Let me know if you run across any bugs, and ill try todo fix them right away.

By Paul sponer. www.blenderart.org
.

-- IMÁGENES ADJUNTAS --

🖼️

Estamos trabajando para mostrar las imágenes del foro

Adjunto #107764



🖼️

Estamos trabajando para mostrar las imágenes del foro

Adjunto #107765



🖼️

Estamos trabajando para mostrar las imágenes del foro

Adjunto #107766



🖼️

Estamos trabajando para mostrar las imágenes del foro

Adjunto #107767



🖼️

Estamos trabajando para mostrar las imágenes del foro

Adjunto #107768



🖼️

Estamos trabajando para mostrar las imágenes del foro

Adjunto #107769



🖼️

Estamos trabajando para mostrar las imágenes del foro

Adjunto #107770