I spent a little bit of time today adding the ‘Select Faces’ right-click functionality for each material in the Meshes and Materials script I’ve been working on. With a mesh selected and a material selected in the list, right-clicking on the material will give you the option to pick. ‘Select Faces’. Picking this option will select the faces that have that material applied to them. I want to work add adding an ‘Apply Material’ option for the right-click menu, that way you can easily apply a different material from the same mesh to other faces. It will be the last thing I’ll add to this script before I move on to something else. I’ll let you know what that is once I finish my work on Meshes and Materials.
This week I’ve continued my work on Meshes and Materials by adding some functionality to the script. First, when the script is run, the ‘Meshes’ list is filled with all polygon meshes in the scene. Secondly, when a mesh is selected in ‘Meshes’ list, all the materials that are assigned to that mesh are displayed in the ‘Materials’ list. For each item in either list I created a right-click menu with ‘Rename’ and ‘Open Attribute Editor’ as options for the selected item. Currently only the ‘Open Attribute Editor’ option works. I’ll work on the ‘Rename’ functionality next weekend. Some other functionality I’ll try to add a ‘Frame Selection’ functionality when the mesh is selected and ‘Select Faces from Material’ when the material from the ‘Materials’ list is selected. So far a so good, I was able to reuse some of the scripts I wrote for JC_selectFacesSameMat and use a lot of what I learned from my readings through Professional MEL Solutions for Production. It’s all coming together.
So for this weeks script I decided to create something that will use some if not all of script I made last week. At least it will eventually use them. For Meshes and Materials I’m creating a small UI that will work as follows:
1. When you run the script a list of all the meshes in the currently opened file will be displayed in a scrollable list (I may or may not select the mesh at the top of the list by default).
2. When you select a mesh on this list, it will populate a second list in the UI that will show all of the material applied to the selected mesh. Selecting a new mesh in the first list will update the second list with a new list of materials. Also each selection will frame that mesh in the view port.
3. Selecting a material name in the second list will select all the faces on that mesh that are assigned the selected material. Selecting a new material on the list will then refresh the selected faces. Selecting the material will select it in the Hypershade and also open the Attribute editor.
4. I will also add a right-click functionality that will allow you to rename the mesh or material. Right-clicking on a material will also give you the option of assigning that material to the current selection.
5. Finally, there will be a refresh button to force a refresh of newly added meshes and materials, though that should happen automatically. I added it just in case. Currently they are two buttons, but I think I can turned this into one.
Today I worked on building the UI and next week will see about adding some of this functionality. This could be a multiple week project but should turn out something fruitful.
Similar to my ZBrush Sculpt of the Day, I’ve decided to give myself one day (more than likely half a day since I’m probably going to do this on the weekends) to come up with a script that will allow you to do something useful in Maya. Today I decided to create a script that will select all the faces on a single mesh that have the same material applied to them. A very handy script I would say. Though Maya does have a “Select Objects with Materials” option in the Hypershade –> Edit menu, it selects everything that has that material. With this script, if you select a single face and run the script, all faces on that single mesh will be selected. Handy if you want to change those faces to another material. It will also select the material in the Hypershade as a bonus in case you want to apply that material to something else.
The script itself could probably have been edited further to be a bit more efficient, but this is just an exercise in trying to put together something quickly that works. Unfortunately I can’t upload .mel files to WordPress so I’ve attached a link here to a Word .doc if you’re interested in checking it out. To run the script, you can easily paste the code to Maya’s Script Editor, save it to your script folder and call as a MEL script command JC_selectFacesSameMat.
The way it works is pretty straight forward. The script first finds the Shading Group and Material of the selected face (wanted to be sure that it had both of these in case a Shading Group was shared). Then it tests to see if the other faces on the mesh have the same Shading Group and Material assigned. If so, it add stores those and when it finishes iterating through all the faces, will select only the faces that match.
Enjoy, I hope you find this useful.
So for those of you making the transition from MEL to Python (like me) when scripting in Maya, I’m pleased to share with you a great resource for getting up to speed. Chris Zurbrigg has a great many tutorials to learn Python, the differences between it and MEL and also a few projects. I’ve just started going through these and feel extremely confident that what I’m learning is going to make my transition into working in Python for Maya extremely quick.
He also has a Maya plugin called Charcoal Editor which is a fantastic upgrade to Maya’s Script Editor. I’ve been using the Demo version and though it won’t allow you to save files it has plenty of functionality. I will most likely buy a license after finishing up with his tutorials. I may even buy two so that I have one handy for working on MAC as well.
Any way, if you’re at all interested in transitioning from MEL to Python, I highly recommend you visit Chris Zurbrigg’s site.
So along with my attempts at picking up shader programming and 3D Math, I’ve squeezed in a bit more of Maya MEL Scripting to keep improving my programming/scripting skills. The most recent book I’ve gone through is, MEL Scripting for Maya Animators. Even though it’s been 8 or so years since the second edition of this book was released, it still contains quite a bit of useful information. Especially the many chapters covering how to create custom user interfaces for your scripts. It was one of the few things about MEL that confused me most when first learning so I’m glad it was well covered in the book. I definitely recommend this book if want to learn or refresh your MEL skills like I wanted to.
There are a couple more books on MEL that I’m currently reading through and will post some additional comments on those when I’ve finished working through them. Professional MEL Solutions for Production and Complete Maya Programming: An Extensive Guide to MEL and the C++ API. “Well look at you Mr. Fancy Pants.” After finishing these, then I’d like to go through Complete Maya Programming: An In-depth Guide to 3D Fundamentals, Geometry, and Modeling, Volume II and MEL Scripting a Character Rig in Maya. What have gotten myself into! I think the 3D math primer I’m also currently reading will help me out quite bit with Volume II of Complete Maya Programming.
So yeah, I’m keeping myself quite busy with some of my free time. Hopefully I’ll leave myself enough time to write more scripts for Maya that I’ve neglected because of all the books I’ve picked up. In any case, wish me luck as I continue my pursuit of becoming a better technical artist.
In my previous post, I talked about learning the Cg Shader language. But the further I got along in my readings, the more I felt I needed to expand my knowledge of 3D Math. In my attempt to jump into Cg programming quickly, I skipped over (what I believe) important prerequisites. So at this time, I’ve paused my readings of The CG Tutorial and have dived into 3D Math. I asked a few of my colleagues at Kixeye if they had any suggestions of where to start and they provided me with a great number of resources to check out.
The first resource I decided to check out is in my digital bookshelf, 3D Math Primer for Graphics and Game Development. The book present the subject of 3D math in a very concise and readable fashion. It’s been a while since I’ve tackled math in general but with the overall goal of writing my own shaders, the task of learning/relearning math has been enjoyable. I hope the skills I learn from this book will give me a better understanding of some of the topics discussed in The CG Tutorial. Wish me luck in my mathematical journey.
If you’re interested, you can check out the companion website for the aptly named: http://gamemath.com/
I always enjoy learning new things about game development and my current flavor of the month is shader programming. I’ve begun by reading ‘The Cg Tutorial: The Definitive Guide to Programmable Real-Time Graphics‘. It is freely available and the NVIDIA website along with a lot of other resources on the subject. It’s a little tough getting into it but lot of tutorials I’ve seen in the past just show you what to type without really explaining the details of what is going on, which to me is frustrating. Not to say they aren’t useful, but I feel more explanation is needed. Even though it has been a slow start, knowing more about what going on under the hood will only make me a stronger computer graphics artist. I’ve gone through the first two chapters and so far everything is making sense more or less. Wish me luck and I’ll start posting the shaders I work on for you to use or learn from.
It’s been almost two weeks since I’ve posted something. I can’t believe I’m only really just realizing that work takes up most of your day. I just recently accepted a 3 month contract position at KIXEYE. I’ll mostly be working continuing to implement the UI for the project I’m assigned to, I’ll also (hopefully) be creating other assets for the game in Unity (FX, Animation, etc). Though I know how to work in Unity, I’ve had no production experience with it. It will be interesting to see how certain aspects of game development are handled. Thank you to all the people who helped me to find this position, hopefully more opportunities will present themselves after the contract is over at the end of November.
Being employed again will probably limit the number of ZBrush Sculpts I do, but I hope to continue that and post other interesting topics about game development. It feels like I’m re-adjusting to get back on a work schedule and once I do I hope that I continue to add more content to my blog as I’ve found it a great way to share the work I do. See you soon.
So this stone wall section was sculpted in about 30 minutes after modeling a quick mesh in Maya. Polypaint and Spotlight are a great combination for adding texture if you have good reference images. It feels so much more intuitive to paint on a 3d surface rather than on a UV map. It’s more fun too. Anyway here’s the stone wall section that could be modified in a variety of ways and then tiled pretty easily if needed.