Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actualbelfegor

Posted 23 June 2013 - 03:45 PM

I am trying to follow Waterlimon pseudo but can't get it to work right:

D3DXVECTOR3 start(0.0f, 0.0f, -5.0f);
    D3DXVECTOR3 end(0.0f, .0f, 5.0f);
    D3DXVECTOR3 mid = (end + start) * 0.5f;

    D3DXMATRIX lWorld, lRot, lTra, lWVP;
    D3DXMatrixTranslation(&lTra, mid.x, mid.y, mid.z);
    lTra.m[0][0] = D3DXVec3Length(&(end - start));
    D3DXMatrixIdentity(&lRot);
    D3DXVECTOR3 xDir = end - start;
    D3DXVec3Normalize(&xDir, &xDir);
    D3DXVECTOR3 zDir = cam->Position - mid;
    D3DXVec3Normalize(&zDir, &zDir);
    D3DXVECTOR3 yDir;
    D3DXVec3Cross(&yDir, &xDir, &zDir);
    D3DXVec3Normalize(&yDir, &yDir);
    lRot.m[0][0] = xDir.x; lRot.m[0][1] = xDir.y; lRot.m[0][2] = xDir.z;
    lRot.m[1][0] = yDir.x; lRot.m[1][1] = yDir.y; lRot.m[1][2] = yDir.z;
    lRot.m[2][0] = zDir.x; lRot.m[2][1] = zDir.y; lRot.m[2][2] = zDir.z;
    lWorld = lRot * lTra;
...

Quad doesn't scale along start-end point and orientation is wrong.


#2belfegor

Posted 23 June 2013 - 03:41 PM

I am trying to follow Waterlimon pseudo but can't get it to work right:

D3DXVECTOR3 start(0.0f, 0.0f, -5.0f);
    D3DXVECTOR3 end(0.0f, .0f, 5.0f);
    D3DXVECTOR3 mid = (end + start) * 0.5f;

    D3DXMATRIX lWorld, lRot, lTra, lWVP;
    D3DXMatrixTranslation(&lTra, mid.x, mid.y, mid.z);
    lTra.m[0][0] = D3DXVec3Length(&(start - end));
    D3DXMatrixIdentity(&lRot);
    D3DXVECTOR3 xDir = end - start;
    D3DXVec3Normalize(&xDir, &xDir);
    D3DXVECTOR3 zDir = cam->Position - mid;
    D3DXVec3Normalize(&zDir, &zDir);
    D3DXVECTOR3 yDir;
    D3DXVec3Cross(&yDir, &xDir, &zDir);
    D3DXVec3Normalize(&yDir, &yDir);
    lRot.m[0][0] = xDir.x; lRot.m[0][1] = xDir.y; lRot.m[0][2] = xDir.z;
    lRot.m[1][0] = yDir.x; lRot.m[1][1] = yDir.y; lRot.m[1][2] = yDir.z;
    lRot.m[2][0] = zDir.x; lRot.m[2][1] = zDir.y; lRot.m[2][2] = zDir.z;
    lWorld = lRot * lTra;
...

Quad doesn't scale along start-end point and orientation is wrong.


#1belfegor

Posted 23 June 2013 - 03:41 PM

I am trying to follow Waterlimon pseudo but can't get it to work right:

D3DXVECTOR3 start(0.0f, 0.0f, -5.0f);
    D3DXVECTOR3 end(0.0f, .0f, 5.0f);
    D3DXVECTOR3 mid = (end + start) * 0.5f;

    D3DXMATRIX lWorld, lRot, lTra, lWVP;
    D3DXMatrixTranslation(&lTra, mid.x, mid.y, mid.z);
    lTra.m[0][1] = D3DXVec3Length(&(start - end));
    D3DXMatrixIdentity(&lRot);
    D3DXVECTOR3 xDir = end - start;
    D3DXVec3Normalize(&xDir, &xDir);
    D3DXVECTOR3 zDir = mid - cam->Position;
    D3DXVec3Normalize(&zDir, &zDir);
    D3DXVECTOR3 yDir;
    D3DXVec3Cross(&yDir, &xDir, &zDir);
    D3DXVec3Normalize(&yDir, &yDir);
    lRot.m[0][0] = xDir.x; lRot.m[0][1] = xDir.y; lRot.m[0][2] = xDir.z;
    lRot.m[1][0] = yDir.x; lRot.m[1][1] = yDir.y; lRot.m[1][2] = yDir.z;
    lRot.m[2][0] = zDir.x; lRot.m[2][1] = zDir.y; lRot.m[2][2] = zDir.z;
    lWorld = lRot * lTra;
...

Quad doesn't scale along start-end point and orientation is wrong.


PARTNERS