Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Maya Programming with Python Cookbook

You're reading from   Maya Programming with Python Cookbook Master complex workflows and conquer the world with Python and Maya

Arrow left icon
Product type Paperback
Published in Jul 2016
Publisher Packt
ISBN-13 9781785283987
Length 266 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (2):
Arrow left icon
Pankaj K P Singh Pankaj K P Singh
Author Profile Icon Pankaj K P Singh
Pankaj K P Singh
 Herbez Herbez
Author Profile Icon Herbez
Herbez
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Preface 1. Getting Started with Maya 2. Creating User Interfaces FREE CHAPTER 3. Working with Geometry 4. Giving Things a Coat of Paint – UVs and Materials 5. Adding Controls – Scripting for Rigging 6. Making Things Move – Scripting for Animation 7. Scripting for Rendering 8. Working with File Input/Output 9. Communicating with the Web 10. Advanced Topics 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)...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Modal Close icon
Modal Close icon