MDX – Line.DrawTransform

This is a Repost

This is my first post on MDX, but i am hoping it will not be my last.  I’m witting 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

One Response to “MDX – Line.DrawTransform”

  1. Sam Says:

    Thank you, it’s true that documentation couldn’t be found anywhere on the internet. Thanks for this contribution, it helped me a lot to draw thick lines in 3D!


Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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: