[gameprogrammer] Re: ID3DXSprite translation problem

ok, google "orthographic projection"

ortho projection is what you want to do when you do 2d rendering in a
3d api such as GL or DX.

In ortho projection, the Z coordinate is basically dropped so
everything is rendered in X and Y coordinates only.

In perspective projection, as things get higher or lower level Z's
their position and size changes (gets smaller or bigger etc) but that
doesn't happen in ortho, which is what you are trying to do.



On Sun, Jun 1, 2008 at 11:00 AM, Roman Hwang <hwang.roman@xxxxxxxxx> wrote:
> Here is my projection matrix construction:
>
> D3DXMatrixPerspectiveFovLH(&proj, D3DX_PI * 0.25, WIDTH/HEIGHT, 1.0f,
> 1000.0f);
>
> On 6/1/08, Alan Wolfe <alan.wolfe@xxxxxxxxx> wrote:
>>
>> it sounds like your project matrix is not what it should be for the
>> operation you are trying to do
>>
>>
>> On Sun, Jun 1, 2008 at 4:34 AM, Roman Hwang <hwang.roman@xxxxxxxxx> wrote:
>> > Hello.
>> >
>> > I am trying to make simple GUI through ID3DXSprite. And I faced a
>> > problem
>> > with sprite's posiition.
>> > I made a button and I wanted to click it by handling WM_LBUTTONDOWN.
>> >
>> > When I am trying to draw a sprite in x=60, y=200, the sprite's position
>> > is
>> > different. It is about 59, 190.
>> > But in 0, 0 everything is ok.
>> >
>> > Maybe somebody had the same problem.
>> >
>> > Here is the code.
>> >
>> > D3DXMATRIX res;
>> > D3DXVECTOR2 scale(1.0f, 1.0f);
>> > D3DXVECTOR2 translate(0, 200);
>> > D3DXMatrixTransformation2D(&res, NULL, 0.0, &scale, NULL, 0.0f,
>> > &translate);
>> > sprite->SetTransform(&res);
>> > if (!upPressed)
>> > {
>> > sprite->Draw(texture, NULL, NULL, NULL, D3DCOLOR_ARGB(255, 255, 255,
>> > 255));
>> > }
>> > else
>> > {
>> > sprite->Draw(texturePressed, NULL, NULL, NULL, D3DCOLOR_ARGB(255, 255,
>> > 255,
>> > 255));
>> > }
>> >
>> > Best regards,
>> > Hwang Roman
>> >
>> >
>> >
>>
>>
>> ---------------------
>> To unsubscribe go to http://gameprogrammer.com/mailinglist.html
>>
>>
>
>

---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html


Other related posts: