Jump to content

  • Log In with Google      Sign In   
  • Create Account

View Matrix for Dx9 Sprites


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
8 replies to this topic

#1 noatom   Members   -  Reputation: 782

Like
0Likes
Like

Posted 23 February 2014 - 04:02 AM

So I have some sprites, and I just want to move the camera,and leave the sprite's positions unchanged.

 

I created a matrix like:

D3DXMATRIX m;
    D3DXMatrixLookAtLH(&m, &D3DXVECTOR3(-150, 0, 0), &D3DXVECTOR3(-150, 0, 0), &D3DXVECTOR3(0, 1, 0));

 

And set it as the view matrix for dx(nothing happened). Then I set it as the view matrix for the sprite's component(nothing happened),i tried setting it up for both,and still,nothing happened.

 

I did try other values but apparently the camera just won't move. What am I doing wrong?



Sponsor:

#2 Juliean   GDNet+   -  Reputation: 2606

Like
0Likes
Like

Posted 23 February 2014 - 04:18 AM

How do you render the sprites? With the LPD3DXSPRITE-interface, or with vertex buffers, shaders, etc... ? In the latter case, one possibility that comes to mind is that in your vertex declaration you set position to D3DDECLUSAGE_POSITIONT (mind the T, it doesn't appear bold here even though I marked it so to draw attention to it), which means sprites are pre-transformed and the vertex shader is skipped. I'm just quessing and can't tell much without more information (like what I asked before, possibly some code/shader code would be nice to), but this is something that happend to me once and left me wondering why my vertex shader transforms had no effect on sprites too.


Edited by Juliean, 23 February 2014 - 04:19 AM.


#3 noatom   Members   -  Reputation: 782

Like
0Likes
Like

Posted 23 February 2014 - 04:38 AM

I'm using the D3DXSPRITE interface



#4 Juliean   GDNet+   -  Reputation: 2606

Like
0Likes
Like

Posted 23 February 2014 - 04:44 AM


I'm using the D3DXSPRITE interface

 

Can you then show the code where you set the view-matrix to the sprite-interface?



#5 noatom   Members   -  Reputation: 782

Like
0Likes
Like

Posted 23 February 2014 - 04:47 AM

        D3DXMATRIX m;
	D3DXMatrixLookAtLH(&m, &D3DXVECTOR3(-150, 50, 0), &D3DXVECTOR3(-149, 50, 0), &D3DXVECTOR3(0, 1, 0));
	D3DXMATRIX w;
	D3DXMatrixIdentity(&w);

	ppSprite->SetWorldViewLH(&w, &m);

	Direct3DManager::getInstance()->d3d_Device->BeginScene();

        // drawing the sprite begins here

There it is



#6 Juliean   GDNet+   -  Reputation: 2606

Like
0Likes
Like

Posted 23 February 2014 - 04:55 AM

I never really used the SetWorldViewLH-method, what happens if you use the SetTransform-method with only the view-matrix instead? Or, if all you want to do is simulate a movement of the sprites due to camera, you could eigther try SetTransform with just a D3DXMatrixTranslation with negative camera position, or use this as world matrix for SetWorldViewLH. Does any of the above work, or at least result in a change of appearance in some way or form?

 

As a small side-note, you can just pass nullptr as the first parameter for the world matrix if it is identity in SetWorldViewLH.


Edited by Juliean, 23 February 2014 - 04:56 AM.


#7 noatom   Members   -  Reputation: 782

Like
0Likes
Like

Posted 23 February 2014 - 04:59 AM

If I just use SetTransform(with the sprite's method), the sprite completely goes away(which it shouldn't cause it's texture is between -250 and 250).

 

And just using translation would make things a little bit more complicated since i have to export the positions of the sprites.



#8 Juliean   GDNet+   -  Reputation: 2606

Like
0Likes
Like

Posted 23 February 2014 - 05:14 AM


If I just use SetTransform(with the sprite's method), the sprite completely goes away(which it shouldn't cause it's texture is between -250 and 250).

 

Does it also go away if you set the camera position to something smaller (like -25 or so)? probably -150/50 has a bigger effect than expected.

 

 

 


And just using translation would make things a little bit more complicated since i have to export the positions of the sprites.

 

Whether you use LookAt or Translation doesn't make any difference, both create a matrix, that matrix is multiplied with the sprites vertex positions, so it doesn't matter, if a Translation-matrix works, you can use that ;)


Edited by Juliean, 23 February 2014 - 05:14 AM.


#9 noatom   Members   -  Reputation: 782

Like
0Likes
Like

Posted 23 February 2014 - 06:46 AM

I'll just use a translation matrix.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS