MDX – Line.DrawTransform

This is my first post on MDX, but i am hoping it will not be my last.  I’m writting an app which relies heavily on it for the presentation layer, it’s all very new to me, and there is little documentation, either from the Microsoft Help or on the web, so I have decided that anything I learn I will post on my blog.

The first contribution is regarding the Direct3D class ‘Line’, and in particular the method

public void DrawTransform(
    Vector3[] vertexList,
    Matrix transform,
    int color
);

Now, this is actually incredibly simple to use, but there is next to no documentation outlining how to use it so here is some sample code which should be called during the render loop.

Vector3[] vertexList = new Vector3[4];
vectorList[0].X = 100; vectorList[0].Y = 100; vectorList[0].Z = -20;
vectorList[1].X = 200; vectorList[1].Y = 100; vectorList[1].Z = -20;
vectorList[2].X = 200; vectorList[2].Y = 200; vectorList[2].Z = -20;
vectorList[3] = vectorList[0];

Matrix lineMatrix = worldMatrix * viewMatrix * projectionMatrix;

Line line = new Line();
line.width = 2;
line.Begin();
line.DrawTransform(vectorList. lineMatrix, System.Drawing.Color.Red);
line.End();

this will draw the outline of a rightangle triangle of width ‘2’, the important bit being to know that the matrix you need to use with this method is the ‘worldViewProjection’ matrix.

Advertisements