Simplify calculation of transform

This commit is contained in:
Benau 2016-10-26 09:08:10 +08:00
parent a38c8f0c19
commit cc3ff7cf9f
2 changed files with 14 additions and 20 deletions

View File

@ -50,16 +50,28 @@ STKTextBillboard::STKTextBillboard(core::stringw text, FontWithFace* font,
void STKTextBillboard::updateAbsolutePosition()
{
// Make billboard always face the camera
scene::ICameraSceneNode* curr_cam =
irr_driver->getSceneManager()->getActiveCamera();
if (!curr_cam) return;
core::quaternion q(curr_cam->getViewMatrix());
q.W = -q.W;
if (Parent)
{
// Override to not use the parent's rotation
AbsoluteTransformation = getRelativeTransformation();
core::vector3df wc = RelativeTranslation;
Parent->getAbsoluteTransformation().transformVect(wc);
AbsoluteTransformation.setTranslation(wc);
q.getMatrix(AbsoluteTransformation, wc);
}
else
AbsoluteTransformation = getRelativeTransformation();
{
q.getMatrix(AbsoluteTransformation, RelativeTranslation);
}
core::matrix4 m;
m.setScale(RelativeScale);
AbsoluteTransformation *= m;
}
scene::IMesh* STKTextBillboard::getTextMesh(core::stringw text, FontWithFace* font)
@ -173,22 +185,6 @@ scene::IMesh* STKTextBillboard::getTextMesh(core::stringw text, FontWithFace* fo
return Mesh;
}
void STKTextBillboard::updateNoGL()
{
scene::ICameraSceneNode* curr_cam =irr_driver->getSceneManager()->getActiveCamera();
btMatrix3x3 m;
m.setFromOpenGLSubMatrix(curr_cam->getViewMatrix().pointer());
btQuaternion q;
m.getRotation(q);
q.setW(-q.getW());
Vec3 hpr;
hpr.setHPR(q);
this->setRotation(hpr.toIrrHPR());
updateAbsolutePosition();
STKMeshSceneNode::updateNoGL();
}
void STKTextBillboard::collectChar(video::ITexture* texture,
const core::rect<float>& destRect,
const core::rect<s32>& sourceRect,

View File

@ -74,8 +74,6 @@ public:
const irr::core::vector3df& position,
const irr::core::vector3df& size);
virtual void updateNoGL() OVERRIDE;
virtual scene::ESCENE_NODE_TYPE getType() const OVERRIDE
{
return scene::ESNT_TEXT;