# [MDX] Rotation in transformed coordinates

## Recommended Posts

Good day, commanders! I have created a speedmeter for the car in CustomVertex.TransformedTextured.Format (XYZRHW). I wаnt to rotate an arrow of speedmeter without change its VB (separate VB for arrow). As it to make through transformation (rotation) of the transformed coordinates? Yours faithfully, Max.

##### Share on other sites
jollyjeffers    1570
Quote:
 Original post by Maxim SkachkovGood day, commanders!

[smile] Good day to you too!

Quote:
 Original post by Maxim SkachkovI have created a speedmeter for the car in CustomVertex.TransformedTextured.Format (XYZRHW).
Just the usage of TransformedTextured is enough to make your task impossible. By providing transformed vertices you are explicitly telling the Direct3D pipeline that you dont want any matrix transformations or vertex shaders applied to it - and that it should pass it straight through to the rasterizer.

Three options:

1. Modify your vertex buffer. You say you dont want to do this, but it is the simplest method (from a coding point of view)

2. Switch to proper 3D geometry and use an orthogonal projection matrix. It's slightly more involved and harder to get pixel-level accuracy, but it enables the transformation units in the pipeline.

3. Use vertex shaders and pass in a simple float2 (x,y) coordinate and let the VS handle the custom transformation for you.

hth
Jack

##### Share on other sites
remigius    1172
Hello again Maxim,

There's also option 4, using Sprite objects to render the speedometer. In the source for my 4e4 game you'll find an example of how this can be implemented. It's a bit messy, but you can find the implementation in Common\Compas.cs.

Hope this helps :)

##### Share on other sites
Jack and remigius!
Thanks for fast replies!
I have decided to not use the modification of vertex buffer - it is not recommended because of the decrease of the productivity (Lock... UnLock everyone render).

I have decided to use sprites. It is simple enough too.

Remigius, I download you sample game and at once have found there

sprite.Transform = Matrix.RotationZ(angle);

Though I could not compile it, but now enough examples of a code to me as programmer.

My project is on a finish lane. The DirectX forum helps to do it more quickly and more qualitatively!

Good Luck to you!