Jump to content

  • Log In with Google      Sign In   
  • Create Account

Billboard problem


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
5 replies to this topic

#1 KurtO   Members   -  Reputation: 230

Like
0Likes
Like

Posted 27 October 2012 - 10:34 AM

Hi, i am using this method for my billboarding.
But it seems that i can only set my billboards at position(0,0,0)
otherwise it displays incorrcect.

I have tried to translate before and after but nothing works.

How can i set any other position than origin?

this is my method:
[source lang="cpp"]void CreateBillboardMatrix(const D3DXVECTOR3& particlePos, const D3DXVECTOR3& cameraPos, D3DXMATRIX& out) { // compute billboard basis D3DXVECTOR3 look = particlePos; look = look - cameraPos; D3DXVec3Normalize(&look,&look); const D3DXVECTOR3 CAMERA_UP_VECTOR(0, 1, 0); D3DXVECTOR3 camUp = CAMERA_UP_VECTOR; D3DXVec3Normalize(&camUp,&camUp); D3DXVECTOR3 right; D3DXVec3Cross(&right,&camUp,&look); D3DXVec3Normalize(&right,&right); D3DXVECTOR3 up; D3DXVec3Cross(&up,&look,&right); D3DXVec3Normalize(&up,&up); // set matrix values D3DXMatrixIdentity(&out); out._11 = right.x; out._12 = right.y; out._13 = right.z; out._21 = up.x; out._22 = up.y; out._23 = up.z; out._31 = look.x; out._32 = look.y; out._33 = look.z; out._41 = particlePos.x; out._42 = particlePos.y; out._43 = particlePos.z; }[/source]

Sponsor:

#2 Geoffrey   Members   -  Reputation: 554

Like
0Likes
Like

Posted 29 October 2012 - 06:21 PM

Can you post a screenshot of the incorrectly displayed billboard, or describe what's wrong please? The code you've posted looks OK to me (assuming that your billboard verts are set up in the correct orientation).
The Trouble With Robots - www.digitalchestnut.com/trouble

#3 KurtO   Members   -  Reputation: 230

Like
0Likes
Like

Posted 30 October 2012 - 01:33 AM

i can get it to work if:

as camera position i use a vector that is from my view of camera to position of the camera.
So the position for the camera i send into the function is (View-Pos)

If the Bilboard is in center (0,0,0) it is working, but i cant get the translation to work with this matrix.

If i translate the billboard after my rotation it gets scew and rotation is strange.

The thing is that the function should translate automatically but this function only work if i set my billboard to (0,0,0) position...

#4 angelmu88   Members   -  Reputation: 228

Like
1Likes
Like

Posted 30 October 2012 - 10:13 AM

Hi, i am using this method for my billboarding.
But it seems that i can only set my billboards at position(0,0,0)
otherwise it displays incorrcect.

I have tried to translate before and after but nothing works.

How can i set any other position than origin?

this is my method:
[source lang="cpp"]void CreateBillboardMatrix(const D3DXVECTOR3& particlePos, const D3DXVECTOR3& cameraPos, D3DXMATRIX& out) { // compute billboard basis D3DXVECTOR3 look = particlePos; look = look - cameraPos; D3DXVec3Normalize(&look,&look); const D3DXVECTOR3 CAMERA_UP_VECTOR(0, 1, 0); D3DXVECTOR3 camUp = CAMERA_UP_VECTOR; D3DXVec3Normalize(&camUp,&camUp); D3DXVECTOR3 right; D3DXVec3Cross(&right,&camUp,&look); D3DXVec3Normalize(&right,&right); D3DXVECTOR3 up; D3DXVec3Cross(&up,&look,&right); D3DXVec3Normalize(&up,&up); // set matrix values D3DXMatrixIdentity(&out); out._11 = right.x; out._12 = right.y; out._13 = right.z; out._21 = up.x; out._22 = up.y; out._23 = up.z; out._31 = look.x; out._32 = look.y; out._33 = look.z; out._41 = particlePos.x; out._42 = particlePos.y; out._43 = particlePos.z; }[/source]


I see an error in your code, the look vector is CameraPos-billboardPos (not the other way around). Take into acount that if you have two positions A and B the vector B-A is facing B.

#5 KurtO   Members   -  Reputation: 230

Like
0Likes
Like

Posted 30 October 2012 - 02:16 PM

ah, that was the problem. now it works and my look vector looks like this instead.

D3DXVECTOR3 look = cameraPos - particlePos;

Thank you very much! =)

#6 KurtO   Members   -  Reputation: 230

Like
0Likes
Like

Posted 30 October 2012 - 03:00 PM

This is not working if not centered at Origin. I can´t understand whyyyy not?
It takes the position of my particle, but the rotation is only correct if the particle is centered.?

I think this method is wrong...




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