Sarah’s Trek

My sister is on a round the world trek at the moment, and is keeping the world updated via the new blog I have created for her at http://sarahmiddlemiss.wordpress.com and of course Flickr.  The internet is so cool.

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.

 

I’ve moved

Well I’ve bit the biscuit and have moved my blog to WordPress.  So welcome all my new readers and please bear with my whilst I now go go through my Windows Live Space and republish some of the better posts.