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.DrawTransform(vectorList. lineMatrix, System.Drawing.Color.Red);

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.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: