Skip to content
This repository has been archived by the owner on Aug 22, 2018. It is now read-only.

SpriteRenderer DrawSprites issue #96

Closed
fdsprod opened this issue Nov 10, 2014 · 6 comments
Closed

SpriteRenderer DrawSprites issue #96

fdsprod opened this issue Nov 10, 2014 · 6 comments
Assignees
Milestone

Comments

@fdsprod
Copy link

fdsprod commented Nov 10, 2014

I'm wondering if there is a way to use the built in Entity rendering but to somehow allow us to pass in a transform that is used by SpriteRenderer.DrawSprites in the Begin call to the SpriteBatch. This would be very handy for doing things like 2d cameras.

If there is already a way to do something like this, please let me know.

@Gavin-Williams
Copy link

I use quads all the time as sprites and render them in a 3d space and use 3d camera's (either with perspective or orthographic projections). It simply allows me to work in a space that seems very natural with camera's.

I haven't yet seen anything about 2d camera's as such though. However, although my matrix math is not good for this stuff, I'm pretty confident you can use the camera matrices to transform your sprite locations manually (as in, perform the matrix / vector multiplications yourself). You can do some pretty crazy stuff with matrices and linear algebra.

@fdsprod
Copy link
Author

fdsprod commented Nov 12, 2014

I'd rather not have to set the matrix on every single sprite in my game for the camera, its much more efficient to set it 1 time on the SpriteBatch. SpriteBatch is built to take in a matrix in the begin call, but unfortunately the current implementation of SpriteRenderer does not allow you to use it :(

@xenux
Copy link

xenux commented Nov 13, 2014

Hello,

Sorry what do you mean exactly by 2D camera ? What do you want to do more precisely?
Currently we have what we called the VirtualResolution of a Game. This sets the resolution of the screen for the SpriteRenderer and the UIRenderer. Can this property achieve what you want to do?

@fdsprod
Copy link
Author

fdsprod commented Nov 13, 2014

Well as an example. In XNA to do a 2d camera you would do something like this https://adambruenderman.wordpress.com/2011/04/05/create-a-2d-camera-in-xna-gs-4-0/

In Paradox3d the ability exists in spritebatch to pass the same matrix in the begin call, and it works perfectly fine if I were to write all the rendering code myself. But if I want to take advantage of the APIs provided by Paradox3d and use the SpriteRenderer already supplied for me I cannot figure out a way to do something like the above example.

Here is the draw sprites code from Paradox3d's SpriteRenderer

    private void DrawSprites(SpriteSortMode sortMode, BlendState blendState)
    {
        foreach (var entities in effectNamesToEntityDatas.Values)
        {
            if (entities.Count == 0)
                continue;

            spriteBatch.Begin(sortMode, blendState, effect:entities[0].Get(SpriteComponent.Key).Effect); 

This begin call does not use the overload to supply a matrix in the fashion I've shown above. So, I'm looking for a work around, or, for a way to be provided to do this in a future release.

Please let me know if its just something I've overlooked.

@fdsprod
Copy link
Author

fdsprod commented Nov 19, 2014

Any update on this?

@xen2 xen2 added this to the beta04 milestone Nov 25, 2014
@xen2 xen2 added the fixed label Nov 25, 2014
@xen2
Copy link
Contributor

xen2 commented Nov 25, 2014

beta04 unified SpriteRenderer & CameraComponent for both 2D and 3D.
Let us know if it matches your needs!

@xen2 xen2 closed this as completed Nov 25, 2014
Benlitz pushed a commit that referenced this issue Dec 1, 2015
…Rename to master-renaming

* commit '754cf28b103301ca0cc99ba9156533cda4b16f43':
  [Core] Changed url prefix for object id references. (PDX-2431)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants