Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3D Transformations #8

Open
RogerGMartins opened this issue Feb 21, 2014 · 2 comments
Open

3D Transformations #8

RogerGMartins opened this issue Feb 21, 2014 · 2 comments

Comments

@RogerGMartins
Copy link

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
Copy link
Owner

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
Copy link
Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants