Re: Surely a simple prob i hope
- From: "ZMan" <zman@xxxxxxxxxxxxxx>
- Date: Tue, 13 Jun 2006 14:06:03 -0700
if you want to talk in screen positions you must use Sprite.Draw2D. When
using the 3d coordinates the final position is determined by the world/view
and projection transforms so you would have to set those up to get pixel
alignment.
Remember that texels and pixels are mesaured differently so if you are not
doing scaling then subtracting 0.5 from the x & y positions will align the
texture to the screen with sprite.draw2d.
--
Zman
http://www.thezbuffer.com - News and information for Managed DirectX
"Daniel" <DanielV@xxxxxxxxxxxxxxxx> wrote in message
news:%23IB9KfvjGHA.3848@xxxxxxxxxxxxxxxxxxxxxxx
Ahh i thought the same thing and yes it is 5pixels so that would explain
it. I should measure by the client rectangular region then.
Anyone got any ideas on the 2d issues? I changed my sprite drawing to
Sprite.Draw2D and that placed it correctly but then i had a load of
problems getting my texture to line up right, apparently its a problem
with the method i read? Sound right?
"Brook" <Brook@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:3FA40C46-C14E-49C1-AEEE-826FD38C0E3A@xxxxxxxxxxxxxxxx
Hi Daniel,
Just in response to the 790/800 pixel issue. I experienced the same thing
and although i never really looked into it, i think it was due to the
window
having a 5 pixel border to the left and right (adding up to 10 pixels).
This
meant that only 790 pixels were actually being displayed. I may be wrong
though :)
ta,
Brook
"Daniel" wrote:
Hey guys
I have a few issues all of which are strange so i hope someone can
clarify
fo rme.
First of all i have a windowed app, 800 x 600 in size.
I write all my mouse positions to the console verytime i move the mouse
and
i find when i move th emouse to the far right edge of my window it goes
to
790...but not 800?
Next i draw a sprite at position 500,0,0
Then draw some 2d text at the same position 500,0
Yet on the screen the 2d text appears about 60pixels more across.
The 2D text seems to be accurate, if i set it to 790 it goes right at
the
edge of my form, as you would expect after the first weird issue of the
edge
being 790 instead of 800.
So why does my sprite not position correctly? ALso note it is not a set
offset, the more i move the sprite across the further the gap between it
and
the text.
I am guessing my sprite is being drawn in a different acis or something
and
i need it to match the one the 2d text is following. how do i do this???
please help
This is my code to initialise my perspective view.
// Set transforms
device.Transform.World = Matrix.Identity;
device.Transform.View = Matrix.Identity;
float aspect = (float)_displaySize.Width / (float)_displaySize.Height;
device.Transform.Projection = Matrix.PerspectiveFieldOfViewLeftHanded(
(float)Math.PI / 3.0f, aspect, 0.1f, 1000.0f );
float centerX = (float)_displaySize.Width / 2.0f;
float centerY = (float)_displaySize.Height / 2.0f;
Vector3 cameraPosition = new Vector3(centerX, centerY, -10.0f);
Vector3 cameraTarget = new Vector3(centerX, centerY, 0.0f);
device.Transform.View = Matrix.LookAtLeftHanded(cameraPosition,
cameraTarget, new Vector3(0.0f, 1.0f, 0.0f));
device.Transform.Projection =
Matrix.OrthoLeftHanded((float)_displaySize.Width,
(float)_displaySize.Height, 1.0f, 10.0f);
// Set render states
device.RenderState.Lighting = false;
.
- References:
- Surely a simple prob i hope
- From: Daniel
- RE: Surely a simple prob i hope
- From: Brook
- Re: Surely a simple prob i hope
- From: Daniel
- Surely a simple prob i hope
- Prev by Date: Re: more than a triangle?
- Next by Date: Sprite.Draw2D
- Previous by thread: Re: Surely a simple prob i hope
- Next by thread: Re: more than a triangle?
- Index(es):
Relevant Pages
|