Example #1
0
        public void OnDrawRuntimeGizmos(RuntimeGizmoDrawer drawer)
        {
            if (_drawGizmos)
            {
                drawer.color = Color.blue;
                for (int i = 0; i < _ribbon.Points.Count - 1; i++)
                {
                    drawer.DrawLine(_ribbon.Points[i].Position, _ribbon.Points[i + 1].Position);
                }

                drawer.color = Color.green;
                for (int i = 0; i < _ribbon.Points.Count; i++)
                {
                    drawer.DrawLine(_ribbon.Points[i].Position, _ribbon.Points[i].Position + _ribbon.Points[i].Normal * 0.02F);
                }

                drawer.color = Color.red;
                for (int i = 0; i < _ribbon.Points.Count - 1; i++)
                {
                    Vector3 binormal = Vector3.Cross(_ribbon.Points[i + 1].Position - _ribbon.Points[i].Position, _ribbon.Points[i + 1].Normal).normalized * 0.04F;
                    drawer.DrawLine(_ribbon.Points[i + 1].Position - binormal, _ribbon.Points[i + 1].Position + binormal);
                    drawer.DrawCube(_ribbon.Points[i + 1].Position + binormal, Vector3.one * 0.005F);
                }
            }
        }
Example #2
0
        public void OnDrawRuntimeGizmos(RuntimeGizmoDrawer drawer)
        {
            if (maybePoseSpline.HasValue)
            {
                var spline = maybePoseSpline.Value;

                drawer.color = LeapColor.brown.WithAlpha(0.4f);

                Vector3?prevPos = null;
                int     numSteps = 32;
                int     drawPosePer = 8, counter = 0;
                float   tStep = 1f / numSteps;
                for (float t = 0f; t <= 1f; t += tStep)
                {
                    var pose = spline.PoseAt(t);

                    if (counter % drawPosePer == 0)
                    {
                        drawer.DrawPose(pose, 0.02f);
                    }

                    if (prevPos.HasValue)
                    {
                        drawer.DrawLine(prevPos.Value, pose.position);
                    }

                    prevPos = pose.position;
                    counter++;
                }

                var renderPose = spline.PoseAt(renderPoseAtT);
                var len        = 0.06f;
                var thick      = 0.01f;
                drawer.PushMatrix();
                drawer.matrix = Matrix4x4.TRS(renderPose.position, renderPose.rotation, Vector3.one);
                drawer.color  = Color.red;
                drawer.DrawCube(Vector3.right * ((len / 2f) + (thick / 2f)), new Vector3(len, thick, thick));
                drawer.color = Color.green;
                drawer.DrawCube(Vector3.up * ((len / 2f) + (thick / 2f)), new Vector3(thick, len, thick));
                drawer.color = Color.blue;
                drawer.DrawCube(Vector3.forward * ((len / 2f) + (thick / 2f)), new Vector3(thick, thick, len));
            }
        }
Example #3
0
        private void drawBoxGizmos(RuntimeGizmoDrawer drawer, Vector3 center, Vector3 radii)
        {
            drawer.DrawWireCube(center, radii * 2f);

            drawer.color = drawer.color.WithAlpha(0.05f);
            int   div    = 3;
            float invDiv = 1f / div;

            for (int i = 0; i < div; i++)
            {
                for (int j = 0; j < div; j++)
                {
                    for (int k = 0; k < div; k++)
                    {
                        drawer.DrawWireCube((center + (new Vector3(i, j, k) - radii) * invDiv * 2),
                                            radii * invDiv * 2f);
                    }
                }
            }

            drawer.color = drawer.color.WithAlpha(0.04f);
            drawer.DrawCube(center, radii * 2f);
        }