Re: 2D in D3D
From: Jeff (a_at_a.com)
Date: Fri, 8 Oct 2004 14:21:53 -0700
Oh, sorry I wasn't more clear. These sprites will all be moving
independently. I couldn't just simply draw them once.
"Chris Hastings" <firstname.lastname@example.org> wrote in message
> Can you give me an example of the type of thing you are doing?
> One thing I have done is created a background scene that has an image and
> several sprites. At initialization, I render all of that to a texture,
> then during the draw, I just render the one texture as a sprite and then
> render other things. At draw time, I can move the background or rotate it
> but I never have to rerender the background texture so there isn't a
> performance hit. That works for me because the background sprites aren't
> changing, I just may need to move the whole scene around. If you need
> each individual sprite to change positions or rotation not relative to the
> whole scene, then I don't think that will work.
> Not sure if that helps, but if you tell me what the sprites are and how
> they are moving, I might be able to give you a better answer,.
> "Jeff" <email@example.com> wrote in message
>> Sort of... it's just that moving the camera with matrix.LookatLH does not
>> affect how Direct3D.Sprites are rendered. I'm assuming this is because
>> they are already transformed...?? Is there a way to have the camera
>> affect the way Direct3D.Sprites are drawn?
>> If not, I guess I could draw all my sprites to a single texture and then
>> render that texture transformed, however, that seems like it would add a
>> bit of additional overhead. Would it not?
>> "Chris Hastings" <firstname.lastname@example.org> wrote in message
>>> Have you looked at using a different render target? That way you can
>>> render to a single texture, and then display the texture transformed and
>>> each one.
>>> Also, have you tried just changing the camera position?
>>> If you need to rotate each sprite individually, rather than rotate the
>>> whole scene, I think you need to do what you are doing, but if you just
>>> want to move everything left or right, or rotate the entire scene, Move
>>> the camera with (change view matrix with matrix.LookatLH) or render to a
>>> texture (created with usage.RenderTarget and pool.default) using
>>> I hope that's what you are asking, let me know if that helps.
>>> "Jeff" <email@example.com> wrote in message
>>>> I'm currently using Direct3D.Sprite to draw several hundred sprites to
>>>> the screen and I would like to be able to rotate all of the sprites (as
>>>> if the camera was rotating) or scale them (as if the camera was zooming
>>>> in or out).
>>>> I know I can translate and scale each one of them individually using
>>>> the Sprite.Transform method, however, shouldn't it be as easy as just
>>>> moving the camera and letting D3D render them at the appropriate
>>>> rotation/scale based off the position of the camera?
>>>> Same thing with translation... instead of moving hundreds of sprites to
>>>> the left each frame (to simulate scrolling) wouldn't it be better to
>>>> just move ONE camera to the right each frame?