コード例 #1
0
ファイル: ParentBrush.cs プロジェクト: mikeage/open-brush
            protected override TrTransform CalculateChildXf(List <PbKnot> parentKnots)
            {
                TrTransform actionInCanvasSpace;
                {
                    PbKnot      knot            = GetAttachKnot(parentKnots);
                    float       rotationDegrees = knot.m_distance * App.UNITS_TO_METERS * m_twist;
                    TrTransform offset          = m_offset;

                    // It's cleaner to tack a TrTransform.S(size) onto the action, but that
                    // would modify .scale, which is currently interpreted as "pointer size"
                    // (affecting control point density) and which is also assumed by most
                    // brushes to be constant.
                    if (m_pressureAffectsOffset)
                    {
                        offset.translation *= knot.m_pressuredSize;
                    }
                    else
                    {
                        offset.translation *= m_brush.BaseSize_LS;
                    }

                    TrTransform action =
                        TrTransform.R(Quaternion.AngleAxis(rotationDegrees, Vector3.forward))
                        * offset;
                    actionInCanvasSpace = action.TransformBy(knot.GetFrame(m_frame));
                }

                var cur = parentKnots[parentKnots.Count - 1];

                return(actionInCanvasSpace * cur.m_pointer);
            }
コード例 #2
0
        public void TestTransformByForBasisChange()
        {
            // This is more a test of TrTransform.TransformBy than anything else
            var zFromU = VrAssetService.kPolyFromUnity;

            // This rotates Unity-forward to Unity-right
            TrTransform xfFwdToRt_U = TrTransform.R(Quaternion.AngleAxis(90, Vector3.up));

            AssertAlmostEqual(Vector3.right, xfFwdToRt_U * Vector3.forward);
            AssertAlmostEqual(Vector3.up, xfFwdToRt_U * Vector3.up);

            // This should rotate Poly-forward to Poly-right (to test)
            TrTransform xfFwdToRt_Z = xfFwdToRt_U.TransformBy(zFromU);

            AssertAlmostEqual(kZRight, xfFwdToRt_Z * kZForward);
            AssertAlmostEqual(kZUp, xfFwdToRt_Z * kZUp);
        }
コード例 #3
0
            protected override TrTransform CalculateChildXf(List <PbKnot> parentKnots)
            {
                PbKnot lastKnot = parentKnots[parentKnots.Count - 1];

                float distanceMeters = lastKnot.m_distance * App.UNITS_TO_METERS;
                float t = O.CyclesPerMeter * distanceMeters + (float)m_strand / O.NumStrands;
                // Our periodic function makes the plait look pretty square; maybe add
                // some rotation to break things up a bit?
                float rotations = (O.CyclesPerMeter * distanceMeters) * O.RotationsPerCycle;

                float       amplitude = lastKnot.m_pressuredSize / 2; // /2 because size is diameter, not radius.
                TrTransform action    =
                    TrTransform.R(rotations * 360, Vector3.forward) *
                    TrTransform.T(SomePeriodicFunction(t) * amplitude);

                TrTransform actionInCanvasSpace = action.TransformBy(lastKnot.GetFrame(AttachFrame.LineTangent));

                return(actionInCanvasSpace * lastKnot.m_pointer);
            }