# Confusion with the texture coordinate system in XNA

I am creating a cow out of primitive shapes, and am using the minecraft cow texture as a placeholder. To create the primitive model I have created a 'model' class and created a sub class 'ModelCow' which inherits from the Model class. Each model contains a List of the component class which is like a sub part of the model. In the creation of the components a texturemap for each component is created, which defines the locations of each texture foreach face for that cube in a texture map for that cow.

The way each texture is determined is the top left pixel of the texture and the bottom right, I had to go through each texture and find the top left x and y and divide them by the width and height respectily - the same thing with the bottom right. The thing is the textures are all one pixel off what they should be i.e it is shifted right too far or one pixel is missing. The question is what am I doing inncorrectly. Am I meant to start counting from zero when I get the x and y/ top and right coordinates for the texture. Also in this case the actual width and height of the texture and subtracted by one, i.e. 32 is 31 and 64 is 63

Example of what I am doing is:

AAAAAAAA

AAAAAAAA

A#AAAAAA

AAAAAAAA

the '#' would be 1, 2 and the width would be 7 and the height would be 3. Is this correct?

Here is the code:

    float width = 63f;
float height = 31f;

// Body
TextureMap bodyMap = new TextureMap();
bodyMap.Add(new Vector4(28f / width, 4f / height, 39f / width, 13f / height), FaceDirection.ZIncreasing);
bodyMap.Add(new Vector4(40f / width, 4f / height, 51f / width, 13f / height), FaceDirection.ZDecreasing);
bodyMap.Add(new Vector4(18f / width, 14f / height, 27f / width, 31f / height), FaceDirection.XDecreasing);
bodyMap.Add(new Vector4(28f / width, 14f / height, 39f / width, 31f / height), FaceDirection.YDecreasing);
bodyMap.Add(new Vector4(40f / width, 14f / height, 51f / width, 31f / height), FaceDirection.XIncreasing);
bodyMap.Add(new Vector4(52f / width, 14f / height, 61f / width, 31f / height), FaceDirection.YIncreasing);
components.Add(Shape.BuildCube(new Vector3(0, 0, 0), new Vector3(0.7f, 0.7875f, 1.30f), bodyMap));


Whereas the first two coordinates are the top left and the last two are the bottom right. X and Y respectively.