24 mValidTrackball(false)
26 mRoot = std::make_shared<Node>();
31 std::shared_ptr<Camera>
const& camera)
43 Set(xSize, ySize, camera);
44 mRoot = std::make_shared<Node>();
49 std::shared_ptr<Camera>
const& camera)
51 if (xSize > 0 && ySize > 0 && camera)
65 LogError(
"Invalid Trackball parameters.");
74 mRoot->AttachChild(
object);
82 mRoot->DetachChild(
object);
88 mRoot->DetachAllChildren();
118 float length0 = sqrt(sqrLength0), invLength0 = 0.0f, z0, z1;
122 invLength0 = 1.0f / length0;
130 z0 = 1.0f - sqrLength0;
131 z0 = (z0 <= 0.0f ? 0.0f : sqrt(z0));
140 float length1 = sqrt(sqrLength1), invLength1 = 0.0f;
144 invLength1 = 1.0f / length1;
152 z1 = 1.0f - sqrLength1;
153 z1 = (z1 <= 0.0f ? 0.0f : sqrt(z1));
163 float dot =
Dot(vec0, vec1);
167 angle = acos(std::min(std::max(dot, -1.0
f), 1.0
f));
174 axis[0] = mY0 * invLength0;
175 axis[1] = -
mX0 * invLength0;
191 axis[0] *
mCamera->GetDVector() +
192 axis[1] *
mCamera->GetUVector() +
193 axis[2] *
mCamera->GetRVector();
201 #if defined(GTE_USE_MAT_VEC) 215 Orthonormalize<4, float>(3,
v);
220 mRoot->localTransform.SetRotation(rotate);
void SetFinalPoint(int x, int y)
Vector< NumRows, Real > GetCol(int c) const
Matrix4x4< float > mInitialOrientation
std::shared_ptr< Node > mRoot
#define LogError(message)
void SetInitialPoint(int x, int y)
DualQuaternion< Real > Dot(DualQuaternion< Real > const &d0, DualQuaternion< Real > const &d1)
void SetCol(int c, Vector< NumRows, Real > const &vec)
Real Normalize(GVector< Real > &v, bool robust=false)
DualQuaternion< Real > Cross(DualQuaternion< Real > const &d0, DualQuaternion< Real > const &d1)
void Attach(std::shared_ptr< Spatial > const &object)
void Detach(std::shared_ptr< Spatial > const &object)
std::shared_ptr< Camera > mCamera
void Set(int xSize, int ySize, std::shared_ptr< Camera > const &camera)