LilyPath icon indicating copy to clipboard operation
LilyPath copied to clipboard

3D Transformations

Open RogerGMartins opened this issue 11 years ago • 2 comments

Hello again mate, I know this is mostly for 2D, however I'm probably going to need some 3D transformations on this.

Should I do this in : private void AddVertex (Vector2 position, Brush brush);

changing this method to and add a matrix to it, something like: private void AddVertex (Vector2 position, Brush brush, Matrix m) { ... vertex.Position = Vector3.Transform(new Vector3(position, 0), m); ... }

RogerGMartins avatar Feb 21 '14 08:02 RogerGMartins

Something like that would probably work (but pass the Matrix by ref). I'd be interested to know how well this works.

you might also consider an overload of AddVertex that just takes a Vector3 instead, and then you can limit where you need to pass around Matrices, say to something like DrawPath.

The only potential snarl I see is that the batch is setup like a SpriteBatch, as an orthographic projection: _standardEffect.Projection = Matrix.CreateOrthographicOffCenter(0, _device.Viewport.Width, _device.Viewport.Height, 0, -1, 1); _standardEffect.World = _transform; _standardEffect.CurrentTechnique.Passes[0].Apply();

So you may need to provide your own effect for any batch that's going to contain a perspective-aware transform.

jaquadro avatar Feb 21 '14 15:02 jaquadro

http://gamedev.stackexchange.com/questions/67493/spritebatch-vertex-shader-world-matrix-change-after-each-draw

I did this for spritebatch, I will do it monday and report back.

I'm not using perspective transformations, so for now I dont really need to change stuff, but I will probably extend in the future!

RogerGMartins avatar Feb 21 '14 17:02 RogerGMartins