void TransformManipulator::spin(const Vector3F & d) { Matrix44F ps; parentSpace(ps); Matrix44F invps = ps; invps.inverse(); const Vector3F worldP = ps.transform(translation()); const Vector3F rotUp = ps.transformAsNormal(hitPlaneNormal()); Vector3F toa = m_currentPoint - worldP; Vector3F tob = toa + d; toa.normalize(); tob.normalize(); float ang = toa.angleBetween(tob, toa.cross(rotUp).reversed()); Vector3F angles; if(m_rotateAxis == AY) angles.set(0.f, ang, 0.f); else if(m_rotateAxis == AZ) angles.set(0.f, 0.f, ang); else angles.set(ang, 0.f, 0.f); m_subject->rotate(angles); setRotationAngles(m_subject->rotationAngles()); }
void TransformManipulator::move(const Vector3F & d) { Matrix44F ps; parentSpace(ps); Matrix44F invps = ps; invps.inverse(); Vector3F od = invps.transformAsNormal(d); m_subject->translate(od); setTranslation(m_subject->translation()); }
bool BaseTransform::intersect(const Ray & ray) const { Matrix44F s = worldSpace(); s.inverse(); Vector3F a = ray.m_origin + ray.m_dir * ray.m_tmin; a = s.transform(a); Vector3F b = ray.m_origin + ray.m_dir * ray.m_tmax; b = s.transform(b); Ray objR(a, b); float hit0, hit1; return getBBox().intersect(objR, &hit0, &hit1); }
void BaseView::frameAll(const BoundingBox & b) { Vector3F eye = b.center(); eye.z = b.getMax(2) + b.distance(0) / hfov() * .55f + 120.f; setEyePosition(eye); Matrix44F m; m.setTranslation(eye); *cameraSpaceR() = m; m.inverse(); *cameraInvSpaceR() = m; setFrustum(1.33f, 1.f, 26.2f, -1.f, -1000.f); }
void SkeletonSubspaceDeformer::calculateSubspaceP() { unsigned i, j, n, nj, vstart; Matrix44F spaceInv; Vector3F p; for(i = 0; i < numVertices(); i++) { p = getDeformedP()[i]; n = m_jointIds[i]._ndim; nj = n - 1; vstart = m_jointIds[i][nj]; for(j = 0; j < nj; j++) { SkeletonJoint * joint = m_skeleton->jointByIndex(m_jointIds[i][j]); spaceInv = joint->worldSpace(); spaceInv.inverse(); m_subspaceP[vstart + j] = spaceInv.transform(p); } } }