jaquadro / LilyPath

A 2D path and shape drawing library for MonoGame and XNA.
MIT License
93 stars 12 forks source link

3D Transformations #8

Open RogerGMartins opened 10 years ago

RogerGMartins commented 10 years ago

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); ... }

jaquadro commented 10 years ago

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.

RogerGMartins commented 10 years ago

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!