Book Image

Maya Programming with Python Cookbook

By : Adrian Herbez
Book Image

Maya Programming with Python Cookbook

By: Adrian Herbez

Overview of this book

Maya is a 3D graphics and animation software, used to develop interactive 3D applications and games with stupendous visual effects. The Maya Programming with Python Cookbook is all about creating fast, powerful automation systems with minimum coding using Maya Python. With the help of insightful and essential recipes, this book will help you improve your modelling skills. Expand your development options and overcome scripting problems encountered whilst developing code in Maya. Right from the beginning, get solutions to complex development concerns faced when implementing as parts of build.
Table of Contents (17 chapters)
Maya Programming with Python Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Creating novel primitives (tetrahedron)


In this example, we'll be creating a brand new (to Maya) geometric primitive—a tetrahedron. Tetrahedrons are simple in principle, but would require numerous steps to create using Maya's interface. As such, they make a great candidate for scripting.

We'll be creating a script that will create a tetrahedron of a given edge width as a polygonal mesh.

Getting ready

Before we start writing code, we'll want to make sure that we have a good grasp on the math behind tetrahedrons. A tetrahedron is the simplest regular polyhedron that consists of four faces, each of which is an equilateral triangle.

Each tetrahedron consists of only four points. For convenience, we'll name the three around the base A, B, and C, and the point at the tip D, as in the following illustration:

To make the math easier, we'll set point A to the origin ([0,0,0]). Because every side of the base is of the same length, we can find point B by simply moving along the x axis by the desired edge...