DirectX 11 Matrices
DirectX 11 Matrices
How can you check in 3D programming to see if one matrix is equal to another for example I have a box that moves about on the screen and, like 2d pong, I want to check if it is at the edge of the screen. Please help.
Re: DirectX 11 Matrices
I suppose what you can do is make the camera stationary then set a binding box if you will. Constrain movement in the world space to be relative to the screen
eg D3DXVECTOR3 Min = -10,-10,0, D3DXVECTOR3 Max = 10, 10,0. zero on the z since you just want side to side movement. Then you set your Velocity as you would in 2d to change directions when x < -10 or x > 10 for instance. problem is, if someones screen is larger or smaller (if in full screen mode)... You'd have to get the back buffer desc and find out the screen size then adjust your constraining box to fix relative to the screen. Not sure if this helps, but i just pulled it off the top of my head lol.
eg D3DXVECTOR3 Min = -10,-10,0, D3DXVECTOR3 Max = 10, 10,0. zero on the z since you just want side to side movement. Then you set your Velocity as you would in 2d to change directions when x < -10 or x > 10 for instance. problem is, if someones screen is larger or smaller (if in full screen mode)... You'd have to get the back buffer desc and find out the screen size then adjust your constraining box to fix relative to the screen. Not sure if this helps, but i just pulled it off the top of my head lol.
Curiosity killed the cat, satisfaction brought him back
Re: DirectX 11 Matrices
for checking if one D3DXMATRIX is equal another there's the == operator
always available, always on, about ~10 years c/c++, java[script], win32/directx api, [x]html/css/php/some asp/sql experience. (all self taught)
Knows English, Spanish and Japanese.
[url=irc://irc.freenode.net/#pchili]irc://irc.freenode.net/#pchili[/url] [url=irc://luisr14.no-ip.org/#pchili]alt[/url] -- join up if ever want real-time help or to just chat --
Knows English, Spanish and Japanese.
[url=irc://irc.freenode.net/#pchili]irc://irc.freenode.net/#pchili[/url] [url=irc://luisr14.no-ip.org/#pchili]alt[/url] -- join up if ever want real-time help or to just chat --
Re: DirectX 11 Matrices
how would this look in the code then
Re: DirectX 11 Matrices
I should probably explain further, if the box offset matrix is equal to the edge of the playing field matrix X where X is a position I want the box to not move any further even when A or D is pressed.
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: DirectX 11 Matrices
I think I would decide whether I wanted a top-down view, using or side view, set the camera and make the boundaries of the world fit inside the viewport. Then I would just need to compare X and Z positions of box to X and Z boundaries for a top-down view or X and Y box and boundaries in a side view. Basically, the logic I would assume would be the same as 2D checks instead of checking if the matrices are the same...matrix of the box probably will never be the SAME as the matrix of the boundaries of the world.
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com