I can see the triangle in the center of the screen if I don't apply any World,View,Projection matrix
How do I modify the World matrix so that the triangle always points to the camera no matter its location in the world?
I can see the triangle in the center of the screen if I don't apply any World,View,Projection matrix
How do I modify the World matrix so that the triangle always points to the camera no matter its location in the world?
the normal way of doing this will be creating rotation matrix using the position of the camera and the triangle in the world
but this is not necessary and it produces wrong results too if the camera is too close to the triangle and not looking directly at it.
I think I just have to mod the View matrix?
Many people do it the wrong way, even the ones at nvidia doing FleX, when you get very close to a ball, it will kind of "let you pass".
solution:
if you are using D3DXMatrixLookAtLH in the HLSL code you just need the View matrix data, before applying the world,view,projection matrices do this...
mMatrx[2] = float3(View._13, View._23, View._33);
mMatrx[0] = normalize(cross(float3(0.0f,1.0f,0.0f), mMatrx[2]));
mMatrx[1] = cross(mMatrx[2], mMatrx[0]);
input.Pos.xyz = mul(input.Pos.xyz, mMatrx);
so that the triangle always points to the camera
rotation matrix using the position of the camera and the triangle ... it produces wrong results too if the camera is too close to the triangle ... I think I just have to mod the View matrix?
If you're using a perspective projection, any object (whatever its distance from the camera) will appear somewhat "distorted" the further away it is from screen center.
Can you describe what you mean by "wrong results," and what you want to see that would be "right results"?
It you change the view matrix, that will change the camera's position, the camera's view angle, or both. In addition, changing the view matrix instead of the object's world matrix won't make a difference as the object's vertices are multiplied by both matrices in any case.