Add camera pixel perfect.
This commit is contained in:
@ -194,6 +194,25 @@ void SceneItemTransform::lookAt(
|
||||
this->setWorldTransform(glm::lookAt(position, target, up));
|
||||
}
|
||||
|
||||
float_t SceneItemTransform::lookAtPixelPerfect(
|
||||
const glm::vec3 &position,
|
||||
const glm::vec3 &look,
|
||||
const float_t viewportHeight,
|
||||
const float_t fov,
|
||||
const float_t scale
|
||||
) {
|
||||
float_t z = (
|
||||
tanf((glm::radians(180.0f) - fov) / 2.0f) *
|
||||
(viewportHeight/2.0f)
|
||||
) / scale;
|
||||
this->lookAt(
|
||||
glm::vec3(position.x, position.y, position.z + z),
|
||||
look,
|
||||
glm::vec3(0, 1, 0)
|
||||
);
|
||||
return z;
|
||||
}
|
||||
|
||||
SceneItemTransform::~SceneItemTransform() {
|
||||
std::for_each(
|
||||
this->children.begin(),
|
||||
|
@ -171,6 +171,24 @@ namespace Dawn {
|
||||
const glm::vec3 up
|
||||
);
|
||||
|
||||
/**
|
||||
* Shorthand combined for lookAt and perspectivePixelPerfectDistance
|
||||
* to allow you to create pixel perfect lookAt camera view matricies.
|
||||
*
|
||||
* @param position Position of the camera. Z is for an offset.
|
||||
* @param look Position in world space this transform looks at.
|
||||
* @param viewportHeight Height of the viewport.
|
||||
* @param fov Field of view (in radians).
|
||||
* @return The Z distance that was calculated.
|
||||
*/
|
||||
float_t lookAtPixelPerfect(
|
||||
const glm::vec3 &position,
|
||||
const glm::vec3 &look,
|
||||
const float_t viewportHeight,
|
||||
const float_t fov,
|
||||
const float_t scale = 1.0f
|
||||
);
|
||||
|
||||
virtual ~SceneItemTransform();
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user