Friday, June 27, 2003

Ah-ha using the same vertex buffer I've now drawn two matrixes in different places in my world.
I'm not sure I've done it the correct way but it seem to work.

Call DrawPrimatives from the device and drawn my quad.

device.DrawPrimitives(PrimitiveType.TriangleFan, 0, 2);

The first 0 being the vertex to start with, the second 2 is the number of triangles. In this case two to make a square.
There seem to be calls to draw rects and such but this way is good for now. I can, if I so wish, have odd shapes in my world.

So that sets the first one down at what is 0,0 dead center of where I am looking.
This seems to be where 'I' place no matter what.
Therefore I need to move myself, place and move myself back.
There are the three Transform types, world, view and projection. I can't really remember too much about each. Projection can be thouht to be the lense of a camera it deals wit transforming 3D co-ords ot 2D space. I'm not sure of the differences between view and world. Here I change the view.

So I create a matrix, they have handy functions to be tinkered with.

change.Translate(10,1,0); // I've called my matrix change.
device.SetTransform(TransformType.View, change)

These are x, y, z. So I was it to move 10 units on the X, and 1 unit on the Y.
So then I change the view vector.
Then I call the draw primatives with the same call again.
Then I cal translate with negative numbers to return me to my origin.
Then set the transform to the view again.

If I don't return to my starting position I can only see the most recently placed I'm not sure why. It could be do with my movement calues or mixing view and world up.

No comments: