void dxJointHinge2::getInfo1( dxJoint::Info1 *info ) { info->m = 4; info->nub = 4; // see if we're powered or at a joint limit for axis 1 limot1.limit = 0; if (( limot1.lostop >= -M_PI || limot1.histop <= M_PI ) && limot1.lostop <= limot1.histop ) { dReal angle = measureAngle(); limot1.testRotationalLimit( angle ); } if ( limot1.limit || limot1.fmax > 0 ) info->m++; // see if we're powering axis 2 (we currently never limit this axis) limot2.limit = 0; if ( limot2.fmax > 0 ) info->m++; }
bool UVRotateTool::doMouseDrag(const InputState& inputState) { assert(m_helper.valid()); Model::BrushFace* face = m_helper.face(); const Plane3& boundary = face->boundary(); const Ray3& pickRay = inputState.pickRay(); const FloatType curPointDistance = pickRay.intersectWithPlane(boundary.normal, boundary.anchor()); const Vec3 curPoint = pickRay.pointAtDistance(curPointDistance); const Mat4x4 toFaceOld = face->toTexCoordSystemMatrix(Vec2f::Null, Vec2f::One, true); const Mat4x4 toWorld = face->fromTexCoordSystemMatrix(Vec2f::Null, Vec2f::One, true); const Vec2f curPointInFaceCoords(toFaceOld * curPoint); const float curAngle = measureAngle(curPointInFaceCoords); const float angle = curAngle - m_initalAngle; const float snappedAngle = Math::correct(snapAngle(angle), 4, 0.0f); const Vec2f oldCenterInFaceCoords = m_helper.originInFaceCoords(); const Vec3 oldCenterInWorldCoords = toWorld * Vec3(oldCenterInFaceCoords); Model::ChangeBrushFaceAttributesRequest request; request.setRotation(snappedAngle); MapDocumentSPtr document = lock(m_document); document->setFaceAttributes(request); // Correct the offsets and the position of the rotation center. const Mat4x4 toFaceNew = face->toTexCoordSystemMatrix(Vec2f::Null, Vec2f::One, true); const Vec2f newCenterInFaceCoords(toFaceNew * oldCenterInWorldCoords); m_helper.setOrigin(newCenterInFaceCoords); const Vec2f delta = (oldCenterInFaceCoords - newCenterInFaceCoords) / face->scale(); const Vec2f newOffset = (face->offset() + delta).corrected(4, 0.0f); request.clear(); request.setOffset(newOffset); document->setFaceAttributes(request); return true; }
bool UVRotateTool::doStartMouseDrag(const InputState& inputState) { assert(m_helper.valid()); if (!inputState.modifierKeysPressed(ModifierKeys::MKNone) || !inputState.mouseButtonsPressed(MouseButtons::MBLeft)) return false; const Model::PickResult& pickResult = inputState.pickResult(); const Model::Hit& angleHandleHit = pickResult.query().type(AngleHandleHit).occluded().first(); if (!angleHandleHit.isMatch()) return false; const Model::BrushFace* face = m_helper.face(); const Mat4x4 toFace = face->toTexCoordSystemMatrix(Vec2f::Null, Vec2f::One, true); const Vec2f hitPointInFaceCoords(toFace * angleHandleHit.hitPoint()); m_initalAngle = measureAngle(hitPointInFaceCoords) - face->rotation(); MapDocumentSPtr document = lock(m_document); document->beginTransaction("Rotate Texture"); return true; }