Game Development Reference
In-Depth Information
private Vector GetCenter()
{
double halfWidth = GetWidth() / 2;
double halfHeight
= GetHeight() / 2;
return new Vector(
_vertexPositions[0].X + halfWidth,
_vertexPositions[0].Y - halfHeight,
_vertexPositions[0].Z);
}
private void InitVertexPositions(Vector position, double width, double
height)
{
double halfWidth = width / 2;
double halfHeight = height / 2;
// Clockwise creation of two triangles to make a quad.
// TopLeft, TopRight, BottomLeft
_vertexPositions[0] = new Vector(position.X - halfWidth, position.Y +
halfHeight, position.Z);
_vertexPositions[1]= new Vector(position.X + halfWidth, position.Y +
halfHeight, position.Z);
_vertexPositions[2]= new Vector(position.X - halfWidth, position.Y -
halfHeight, position.Z);
// TopRight, BottomRight, BottomLeft
_vertexPositions[3]= new Vector(position.X + halfWidth, position.Y +
halfHeight, position.Z);
_vertexPositions[4]= new Vector(position.X + halfWidth, position.Y -
halfHeight, position.Z);
_vertexPositions[5]= new Vector(position.X - halfWidth, position.Y -
halfHeight, position.Z);
}
public double GetWidth()
{
// topright - topleft
return _vertexPositions[1].X - _vertexPositions[0].X;
}
Search WWH ::




Custom Search