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

Writing binary data


So far in this chapter, we've looked at reading and writing text-based data formats. This will allow you to work with many types of data (and to easily create your own formats), but it's only half of the picture. In this example, we'll look at the other half-binary formats.

Getting ready

In this example, we'll be writing out a binary version of our FOO file. We'll call such files FOB (foo, binary). As was the case with FOO files, FOB files are a scaled-down example of the types of things that are often encountered in real formats. FOB files will contain the same data we saw in FOO files, namely a list of object types and positions, but stored in a way common to binary formats.

Most binary files consist of two main parts:

  • A header, which is a fixed-size chunk that describes the nature of the rest of the document.

  • Entries that are read according to the data layout specified in the header.

In the case of our FOB files, our header will contain the following:

  • An integer (1 byte)...