Commit 7b1b9b8d authored by Alexander Wiebel's avatar Alexander Wiebel
Browse files

[ADD] new transformation function

parent 59da72da
......@@ -386,6 +386,22 @@ wmath::WVector3D WGridRegular3D::worldCoordToTexCoord( wmath::WPosition point )
r[1] += 0.5 / m_nbPosY;
r[2] += 0.5 / m_nbPosZ;
return r;
}
wmath::WPosition WGridRegular3D::texCoordToWorldCoord( wmath::WVector3D coords )
{
wmath::WVector3D r( wmath::transformPosition3DWithMatrix4D( m_matrix, coords ) );
// Correct the coordinates to have the position at the center of the texture voxel.
r[0] -= 0.5 / m_nbPosX;
r[1] -= 0.5 / m_nbPosY;
r[2] -= 0.5 / m_nbPosZ;
// Scale to [0,max]
r[0] = r[0] * m_nbPosX;
r[1] = r[1] * m_nbPosY;
r[2] = r[2] * m_nbPosZ;
return r;
}
......
......@@ -250,10 +250,16 @@ public:
/**
* Transforms world coordinates to texture coordinates.
* \param point The point with these coordinated will be transformed.
* \param point The point with these coordinates will be transformed.
*/
wmath::WVector3D worldCoordToTexCoord( wmath::WPosition point );
/**
* Transforms texture coordinates to world coordinates.
* \param point The point with these coordinates will be transformed.
*/
wmath::WPosition texCoordToWorldCoord( wmath::WVector3D coords );
/**
* Returns the i'th voxel where the given position belongs too.
*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment