CHAPTER 4 ■ WORKING WITH MODELS
349
return modelVertices;
}
}
}
4-15. Gain Direct Access to Vertex Position Data
by Defining a Custom TypeWriter and TypeReader
The Problem
You want to have access to the position of each vertex inside your Model. Instead of one huge
list containing three Vector3s for each triangle of the Model, you want a list of Triangle objects,
where each Triangle object contains three Vector3s.
Or, more generally, you want to pass an object of a custom class from a custom content
processor to your XNA application. The content pipeline will not know how it should serialize
and deserialize objects of your new class to and from a binary file, so you have to define your
own TypeWriter and TypeReader.
The Solution
The base code ...