コード例 #1
0
        protected override void OnDebugRender(DebugGeometry debugGeometry,
                                              ref Mat4 bodyTransform, bool simpleGeometry)
        {
            Bounds localBounds = new Bounds(-halfDimensions, halfDimensions);
            Mat4   t           = bodyTransform;

            if (!IsIdentityTransform)
            {
                t *= GetTransform();
            }
            Box box = new Box(localBounds) * t;

            debugGeometry.AddBox(box);
        }
コード例 #2
0
            protected void AddSphere(Sphere sphere, double lineThickness, double drawShadowsFactor)
            {
                double radius2 = sphere.Radius;

                if (drawShadowsFactor != 0)
                {
                    radius2 += lineThickness * drawShadowsFactor;
                }

                DebugGeometry.AddSphere(sphere.Origin, radius2, 32, true);

                //Vec3[] positions;
                //int[] indices;
                //SimpleMeshGenerator.GenerateSphere( radius2, 10, 10, false, out positions, out indices );

                //Mat4 transform = Mat4.FromTranslate( sphere.Origin );
                //DebugGeometry.AddVertexIndexBuffer( positions, indices, transform, false, true );
            }
コード例 #3
0
            protected void AddPolygonalChain(Vector3[] points, double radius, double drawShadowsFactor)
            {
                if (points.Length < 2)
                {
                    return;
                }

                double radius2 = radius;

                if (drawShadowsFactor != 0)
                {
                    radius2 *= 2.5 * drawShadowsFactor;                    //2.7f;
                }
                Vector3 center = Vector3.Zero;

                foreach (Vector3 point in points)
                {
                    center += point;
                }
                center /= points.Length;

                Vector3[] localPoints = new Vector3[points.Length];
                for (int n = 0; n < points.Length; n++)
                {
                    localPoints[n] = points[n] - center;
                }

                Vector3[] positions;
                int[]     indices;
                SimpleMeshGenerator.GeneratePolygonalChain(localPoints, radius2, out positions, out indices);

                Matrix4 transform = Matrix4.FromTranslate(center);

                DebugGeometry.AddTriangles(positions, indices, transform, false, true);

                //for( int n = 0; n < points.Length - 1; n++ )
                //{
                //   Vec3 p1 = points[ n ];
                //   Vec3 p2 = points[ n + 1 ];
                //   AddLine( p1, p2, thickness, drawShadows );
                //}
            }
コード例 #4
0
            protected void AddCone(Vector3 from, Vector3 to, double radius, double lineThickness, double drawShadowsFactor)
            {
                Vector3 from2   = from;
                Vector3 to2     = to;
                double  radius2 = radius;

                if (drawShadowsFactor != 0)
                {
                    Vector3 direction2 = (to2 - from2).GetNormalize();
                    from2   -= direction2 * lineThickness * 0.4 * drawShadowsFactor;
                    to2     += direction2 * lineThickness * 3 * drawShadowsFactor;
                    radius2 += lineThickness * 1.5f * drawShadowsFactor;
                }

                double  length = (to2 - from2).Length();
                Matrix4 t      = new Matrix4(Quaternion.FromDirectionZAxisUp(to2 - from2).ToMatrix3(), from2);

                DebugGeometry.AddCone(t, 0, SimpleMeshGenerator.ConeOrigin.Bottom, radius2, length, 32, 32, true);

                //double length = ( to2 - from2 ).Length();

                //Vec3 direction = to2 - from2;
                //if( direction == Vec3.Zero )
                //	direction = Vec3.XAxis;
                //direction.Normalize();

                ////var rotation = Mat3.LookAt( to2 - from2, Vec3.ZAxis );
                ////double length = direction.Normalize();

                //Vec3[] positions;
                //int[] indices;
                //SimpleMeshGenerator.GenerateCone( 0, SimpleMeshGenerator.ConeOrigin.Bottom, radius2, length, 32, true, true, out positions, out indices );

                ////Mat4 transform = new Mat4( rotation, from2 );
                //Quat rotation = Quat.FromDirectionZAxisUp( direction );
                //Mat4 transform = new Mat4( rotation.ToMat3(), from2 );

                //DebugGeometry.AddVertexIndexBuffer( positions, indices, transform, false, true );
            }
コード例 #5
0
            public override void OnRender()
            {
                base.OnRender();

                if (!Owner.IsAllowRotate())
                {
                    return;
                }

                ColorValue yellow      = new ColorValue(1, 1, 0);
                ColorValue red         = new ColorValue(1, 0, 0);
                ColorValue green       = new ColorValue(0, 1, 0);
                ColorValue blue        = new ColorValue(0, 0, 1);
                ColorValue gray        = new ColorValue(.66f, .66f, .66f);
                ColorValue darkGray    = new ColorValue(.33f, .33f, .33f);
                ColorValue shadowColor = new ColorValue(0, 0, 0, ProjectSettings.Get.TransformToolShadowIntensity);

                Axis axis = Axis.None;

                if (!Viewport.MouseRelativeMode)
                {
                    if (!modify_Activated)
                    {
                        Vector2 dummy1;
                        Radian  dummy2;
                        axis = GetAxisByMousePosition(out dummy1, out dummy2);
                    }
                    else
                    {
                        axis = selectedAxis;
                    }
                }

                Vector3 position;

                if (!modify_Activated)
                {
                    position = Owner.GetPosition();
                }
                else
                {
                    position = modifyPosition;
                }
                double lineThickness = GetLineWorldThickness(position);
                double radius        = GetSize();

                if (radius == 0)
                {
                    return;
                }

                //DebugGeometry.SetSpecialDepthSettings( false, true );

                const double step = MathEx.PI / 64;

                double     innerRadius    = radius * .75f;
                double     cameraDistance = GetCameraDistance(position);
                Vector3    cameraRight    = Vector3.Cross(CameraSettings.Direction, CameraSettings.Up);
                Vector3    oldPos         = Vector3.Zero;
                Quaternion startRotation  = GetStartObjectsRotation();

                for (int nDrawStep = 0; nDrawStep < 5; nDrawStep++)
                {
                    bool drawShadows = nDrawStep <= 3;
                    if (drawShadows && ProjectSettings.Get.TransformToolShadowIntensity == 0)
                    {
                        continue;
                    }

                    var drawShadowsFactor = 0.0;
                    if (drawShadows)
                    {
                        drawShadowsFactor = ((double)nDrawStep + 1.0) / 4.0;
                    }

                    if (drawShadows)
                    {
                        DebugGeometry.SetColor(shadowColor * new ColorValue(1, 1, 1, 0.25), false);                            //, true );
                    }
                    //Fill inner circle
                    if (axis == Axis.InnerCircle && !drawShadows)
                    {
                        if (!drawShadows)
                        {
                            DebugGeometry.SetColor(new ColorValue(1, 1, 0, .4f), false);                                //, true );
                        }
                        //DebugGeometry.Color = new ColorValue( .2f, .2f, .2f, .33f );

                        List <Vector3> vertices = new List <Vector3>();

                        for (double angle = 0; angle <= MathEx.PI * 2 + step * .5f; angle += step)
                        {
                            Vector3 pos = position;
                            pos += cameraRight * Math.Cos(angle) * innerRadius;
                            pos += CameraSettings.Up * Math.Sin(angle) * innerRadius;

                            if (angle != 0)
                            {
                                int verticesCount = vertices.Count;

                                vertices.Add(position);
                                vertices.Add(oldPos);
                                vertices.Add(pos);
                            }
                            oldPos = pos;
                        }

                        DebugGeometry.AddTriangles(vertices, Matrix4.Identity, false, false);
                    }

                    //!!!!тут?
                    //render axes of objects
                    if (!drawShadows && Owner.Objects.Count <= 30)
                    {
                        foreach (TransformToolObject gizmoObject in Owner.Objects)
                        {
                            var    size      = radius / 3;
                            double alpha     = 1;                        // 0.333;
                            double thickness = GetLineWorldThickness(gizmoObject.Position);

                            Matrix4 transform = new Matrix4(gizmoObject.Rotation.ToMatrix3() * Matrix3.FromScale(new Vector3(size, size, size)), gizmoObject.Position);

                            var headHeight = size / 4;
                            DebugGeometry.SetColor(new ColorValue(1, 0, 0, alpha), false);                                //, true );
                            DebugGeometry.AddArrow(transform * Vector3.Zero, transform * Vector3.XAxis, headHeight, 0, true, thickness);
                            DebugGeometry.SetColor(new ColorValue(0, 1, 0, alpha), false);                                //, true );
                            DebugGeometry.AddArrow(transform * Vector3.Zero, transform * Vector3.YAxis, headHeight, 0, true, thickness);
                            DebugGeometry.SetColor(new ColorValue(0, 0, 1, alpha), false);                                //, true );
                            DebugGeometry.AddArrow(transform * Vector3.Zero, transform * Vector3.ZAxis, headHeight, 0, true, thickness);
                        }
                    }

                    //Inner circle
                    {
                        List <Vector3> points = new List <Vector3>(64);
                        for (double angle = 0; angle <= MathEx.PI * 2 + step * .5f; angle += step)
                        {
                            Vector3 pos = position;
                            pos += cameraRight * Math.Cos(angle) * innerRadius;
                            pos += CameraSettings.Up * Math.Sin(angle) * innerRadius;
                            points.Add(pos);
                        }
                        if (!drawShadows)
                        {
                            DebugGeometry.SetColor(darkGray, false);                              //, true );
                        }
                        AddPolygonalChain(points.ToArray(), lineThickness, drawShadowsFactor);
                    }
                    //if( !drawShadows )
                    //   DebugGeometry.Color = darkGray;
                    //for( double angle = 0; angle <= MathEx.PI * 2 + step * .5f; angle += step )
                    //{
                    //   Vec3 pos = position;
                    //   pos += cameraRight * Math.Cos( angle ) * innerRadius;
                    //   pos += camera.Up * Math.Sin( angle ) * innerRadius;
                    //   if( angle != 0 )
                    //      AddLine( oldPos, pos, lineThickness, drawShadows );
                    //   oldPos = pos;
                    //}

                    //Radius
                    if (!Owner.SceneMode2D)
                    {
                        List <Vector3> points = new List <Vector3>(64);
                        for (double angle = 0; angle <= MathEx.PI * 2 + step * .5f; angle += step)
                        {
                            Vector3 pos = position;
                            pos += cameraRight * Math.Cos(angle) * radius;
                            pos += CameraSettings.Up * Math.Sin(angle) * radius;
                            points.Add(pos);
                        }
                        if (!drawShadows)
                        {
                            DebugGeometry.SetColor((axis == Axis.Radius) ? yellow : gray, false);                                //, true );
                        }
                        AddPolygonalChain(points.ToArray(), lineThickness, drawShadowsFactor);
                    }
                    //if( !drawShadows )
                    //   DebugGeometry.Color = ( axis == Axis.Radius ) ? yellow : gray;
                    //for( double angle = 0; angle <= MathEx.PI * 2 + step * .5f; angle += step )
                    //{
                    //   Vec3 pos = position;
                    //   pos += cameraRight * Math.Cos( angle ) * radius;
                    //   pos += camera.Up * Math.Sin( angle ) * radius;
                    //   if( angle != 0 )
                    //      AddLine( oldPos, pos, lineThickness, drawShadows );
                    //   oldPos = pos;
                    //}

                    //X
                    {
                        List <Vector3> points    = new List <Vector3>(64);
                        List <bool>    skipLines = new List <bool>(64);
                        for (double angle = 0; angle <= MathEx.PI * 2 + step * .5f; angle += step)
                        {
                            Vector3 pos = position + startRotation * (new Vector3(0, Math.Sin(angle),
                                                                                  Math.Cos(angle)) * innerRadius);
                            points.Add(pos);
                            bool skip = GetCameraDistance(pos) > cameraDistance;
                            skipLines.Add(skip);
                            //if( angle != 0 && GetCameraDistance( pos ) <= cameraDistance )
                            //   points.Add( pos );
                        }
                        if (!drawShadows)
                        {
                            DebugGeometry.SetColor((axis == Axis.X) ? yellow : red, false);                                //, true );
                        }
                        List <Vector3> newPoints = new List <Vector3>(64);
                        for (int n = 0; n < points.Count; n++)
                        {
                            if (!skipLines[n])
                            {
                                newPoints.Add(points[n]);
                            }
                            else
                            {
                                if (newPoints.Count != 0)
                                {
                                    AddPolygonalChain(newPoints.ToArray(), lineThickness, drawShadowsFactor);
                                    newPoints.Clear();
                                }
                            }
                        }
                        if (newPoints.Count != 0)
                        {
                            AddPolygonalChain(newPoints.ToArray(), lineThickness, drawShadowsFactor);
                            newPoints.Clear();
                        }
                    }
                    //for( double angle = 0; angle <= MathEx.PI * 2 + step * .5f; angle += step )
                    //{
                    //   Vec3 pos = position + startRotation * ( new Vec3( 0, Math.Sin( angle ),
                    //      Math.Cos( angle ) ) * innerRadius );
                    //   if( angle != 0 && GetCameraDistance( pos ) <= cameraDistance )
                    //      AddLine( oldPos, pos, lineThickness, drawShadows );
                    //   oldPos = pos;
                    //}

                    //Y
                    {
                        List <Vector3> points    = new List <Vector3>(64);
                        List <bool>    skipLines = new List <bool>(64);
                        for (double angle = 0; angle <= MathEx.PI * 2 + step * .5f; angle += step)
                        {
                            Vector3 pos = position + startRotation * (new Vector3(Math.Sin(angle), 0,
                                                                                  Math.Cos(angle)) * innerRadius);
                            points.Add(pos);
                            bool skip = GetCameraDistance(pos) > cameraDistance;
                            skipLines.Add(skip);
                            //if( angle != 0 && GetCameraDistance( pos ) <= cameraDistance )
                            //   points.Add( pos );
                        }
                        if (!drawShadows)
                        {
                            DebugGeometry.SetColor((axis == Axis.Y) ? yellow : green, false);                                //, true );
                        }
                        List <Vector3> newPoints = new List <Vector3>(64);
                        for (int n = 0; n < points.Count; n++)
                        {
                            if (!skipLines[n])
                            {
                                newPoints.Add(points[n]);
                            }
                            else
                            {
                                if (newPoints.Count != 0)
                                {
                                    AddPolygonalChain(newPoints.ToArray(), lineThickness, drawShadowsFactor);
                                    newPoints.Clear();
                                }
                            }
                        }
                        if (newPoints.Count != 0)
                        {
                            AddPolygonalChain(newPoints.ToArray(), lineThickness, drawShadowsFactor);
                            newPoints.Clear();
                        }
                    }
                    //if( !drawShadows )
                    //   DebugGeometry.Color = ( axis == Axis.Y ) ? yellow : green;
                    //for( double angle = 0; angle <= MathEx.PI * 2 + step * .5f; angle += step )
                    //{
                    //   Vec3 pos = position + startRotation * ( new Vec3( Math.Sin( angle ), 0,
                    //      Math.Cos( angle ) ) * innerRadius );
                    //   if( angle != 0 && GetCameraDistance( pos ) <= cameraDistance )
                    //      AddLine( oldPos, pos, lineThickness, drawShadows );
                    //   oldPos = pos;
                    //}

                    //Z
                    {
                        List <Vector3> points    = new List <Vector3>(64);
                        List <bool>    skipLines = new List <bool>(64);
                        for (double angle = 0; angle <= MathEx.PI * 2 + step * .5f; angle += step)
                        {
                            Vector3 pos = position + startRotation * (new Vector3(Math.Sin(angle),
                                                                                  Math.Cos(angle), 0) * innerRadius);
                            points.Add(pos);
                            bool skip = GetCameraDistance(pos) > cameraDistance;
                            if (Owner.SceneMode2D)
                            {
                                skip = false;
                            }
                            skipLines.Add(skip);
                            //if( angle != 0 && GetCameraDistance( pos ) <= cameraDistance )
                            //   points.Add( pos );
                        }
                        if (!drawShadows)
                        {
                            DebugGeometry.SetColor((axis == Axis.Z) ? yellow : blue, false);                                //, true );
                        }
                        List <Vector3> newPoints = new List <Vector3>(64);
                        for (int n = 0; n < points.Count; n++)
                        {
                            if (!skipLines[n])
                            {
                                newPoints.Add(points[n]);
                            }
                            else
                            {
                                if (newPoints.Count != 0)
                                {
                                    AddPolygonalChain(newPoints.ToArray(), lineThickness, drawShadowsFactor);
                                    newPoints.Clear();
                                }
                            }
                        }
                        if (newPoints.Count != 0)
                        {
                            AddPolygonalChain(newPoints.ToArray(), lineThickness, drawShadowsFactor);
                            newPoints.Clear();
                        }
                    }
                    //if( !drawShadows )
                    //   DebugGeometry.Color = ( axis == Axis.Z ) ? yellow : blue;
                    //for( double angle = 0; angle <= MathEx.PI * 2 + step * .5f; angle += step )
                    //{
                    //   Vec3 pos = position + startRotation * ( new Vec3( Math.Sin( angle ),
                    //      Math.Cos( angle ), 0 ) * innerRadius );
                    //   if( angle != 0 && GetCameraDistance( pos ) <= cameraDistance )
                    //      AddLine( oldPos, pos, lineThickness, drawShadows );
                    //   oldPos = pos;
                    //}

                    //Arrows
                    if (axis != Axis.None && axis != Axis.InnerCircle)
                    {
                        Plane plane = new Plane();
                        switch (axis)
                        {
                        case Axis.X: plane = Plane.FromPointAndNormal(position, GetStartObjectsRotation() * Vector3.XAxis); break;

                        case Axis.Y: plane = Plane.FromPointAndNormal(position, GetStartObjectsRotation() * Vector3.YAxis); break;

                        case Axis.Z: plane = Plane.FromPointAndNormal(position, GetStartObjectsRotation() * Vector3.ZAxis); break;

                        case Axis.Radius: plane = Plane.FromPointAndNormal(position, CameraSettings.Direction); break;
                        }

                        Vector2 mouse;
                        if (modify_Activated || initialObjectsTransform != null)
                        {
                            mouse = mouseStartPosition;
                        }
                        else
                        {
                            mouse = Viewport.MousePosition;
                        }
                        Ray ray = CameraSettings.GetRayByScreenCoordinates(mouse);

                        Vector3 planeIntersection;
                        if (plane.Intersects(ray, out planeIntersection))
                        {
                            Vector3 direction = (planeIntersection - position).GetNormalize();
                            Vector3 arrowCenter;
                            if (axis == Axis.Radius)
                            {
                                arrowCenter = position + direction * radius;
                            }
                            else
                            {
                                arrowCenter = position + direction * innerRadius;
                            }

                            double arrowLength = radius * .3f;

                            Vector3 tangent        = Vector3.Cross(direction, plane.Normal);
                            Vector3 arrowPosition1 = arrowCenter + tangent * arrowLength;
                            Vector3 arrowPosition2 = arrowCenter - tangent * arrowLength;

                            if (!drawShadows)
                            {
                                DebugGeometry.SetColor(yellow, false);                                  //, true );
                            }
                            {
                                Vector3 direction1 = (arrowPosition1 - arrowCenter).GetNormalize();
                                AddCone(
                                    arrowCenter + direction1 * arrowLength / 2,
                                    arrowPosition1,
                                    arrowLength / 8, lineThickness, drawShadowsFactor);
                            }
                            {
                                Vector3 direction2 = (arrowPosition2 - arrowCenter).GetNormalize();
                                AddCone(
                                    arrowCenter + direction2 * arrowLength / 2,
                                    arrowPosition2,
                                    arrowLength / 8, lineThickness, drawShadowsFactor);
                            }
                        }
                    }
                }

                //DebugGeometry.RestoreDefaultDepthSettings();
            }
コード例 #6
0
 protected double GetLineWorldThickness(Vector3 position)
 {
     return(DebugGeometry.GetThicknessByPixelSize(position, ProjectSettings.Get.TransformToolLineThicknessScaled));
 }
コード例 #7
0
            public override void OnRender()
            {
                base.OnRender();

                if (!Owner.IsAllowScale())
                {
                    return;
                }

                ColorValue yellow      = new ColorValue(1, 1, 0);
                ColorValue red         = new ColorValue(1, 0, 0);
                ColorValue green       = new ColorValue(0, 1, 0);
                ColorValue blue        = new ColorValue(0, 0, 1);
                ColorValue shadowColor = new ColorValue(0, 0, 0, ProjectSettings.Get.TransformToolShadowIntensity);

                Axes axes = new Axes(false, false, false);

                if (!Viewport.MouseRelativeMode)
                {
                    if (!modify_Activated)
                    {
                        axes = GetAxesByMousePosition();
                    }
                    else
                    {
                        axes = selectedAxes;
                    }
                }

                Vector3 position      = Owner.GetPosition();
                double  lineThickness = GetLineWorldThickness(position);
                double  size          = GetSize();

                if (size == 0)
                {
                    return;
                }

                //!!!!review. גוחהו ג ‎עמל פאיכו
                //DebugGeometry.SetSpecialDepthSettings( false, true );

                Vector3 xOffset, yOffset, zOffset;

                GetAxisOffsets(out xOffset, out yOffset, out zOffset);

                //Arrows
                for (int nDrawStep = 0; nDrawStep < 5; nDrawStep++)
                {
                    bool drawShadows = nDrawStep <= 3;
                    if (drawShadows && ProjectSettings.Get.TransformToolShadowIntensity == 0)
                    {
                        continue;
                    }

                    var drawShadowsFactor = 0.0;
                    if (drawShadows)
                    {
                        drawShadowsFactor = ((double)nDrawStep + 1.0) / 4.0;
                    }

                    if (drawShadows)
                    {
                        DebugGeometry.SetColor(shadowColor * new ColorValue(1, 1, 1, 0.25), false);                            //, true );
                    }
                    //X
                    if (!drawShadows)
                    {
                        DebugGeometry.SetColor((axes.x && axes.TrueCount != 3) ? yellow : red, false);                            //, true );
                    }
                    AddLine(position, position + xOffset, lineThickness, drawShadowsFactor);
                    AddSphere(new Sphere(position + xOffset, size / 80), lineThickness, drawShadowsFactor);
                    AddSphere(new Sphere(position + xOffset, size / 40), lineThickness, drawShadowsFactor);

                    if (!drawShadows)
                    {
                        DebugGeometry.SetColor(axes.x && axes.y ? yellow : red, false);                          //, true );
                    }
                    AddLine(position + xOffset * .7f, position + (xOffset * .7f + yOffset * .7f) / 2,
                            lineThickness, drawShadowsFactor);
                    AddLine(position + xOffset * .5f, position + (xOffset * .5f + yOffset * .5f) / 2,
                            lineThickness, drawShadowsFactor);
                    if (!drawShadows)
                    {
                        DebugGeometry.SetColor(axes.x && axes.z ? yellow : red, false);                          //, true );
                    }
                    AddLine(position + xOffset * .7f, position + (xOffset * .7f + zOffset * .7f) / 2,
                            lineThickness, drawShadowsFactor);
                    AddLine(position + xOffset * .5f, position + (xOffset * .5f + zOffset * .5f) / 2,
                            lineThickness, drawShadowsFactor);

                    //Y
                    if (!drawShadows)
                    {
                        DebugGeometry.SetColor((axes.y && axes.TrueCount != 3) ? yellow : green, false);                            //, true );
                    }
                    AddLine(position, position + yOffset,
                            lineThickness, drawShadowsFactor);
                    AddSphere(new Sphere(position + yOffset, size / 80), lineThickness, drawShadowsFactor);
                    AddSphere(new Sphere(position + yOffset, size / 40), lineThickness, drawShadowsFactor);

                    if (!drawShadows)
                    {
                        DebugGeometry.SetColor(axes.y && axes.x ? yellow : green, false);                          //, true );
                    }
                    AddLine(position + yOffset * .7f, position + (yOffset * .7f + xOffset * .7f) / 2,
                            lineThickness, drawShadowsFactor);
                    AddLine(position + yOffset * .5f, position + (yOffset * .5f + xOffset * .5f) / 2,
                            lineThickness, drawShadowsFactor);
                    if (!drawShadows)
                    {
                        DebugGeometry.SetColor(axes.y && axes.z ? yellow : green, false);                          //, true );
                    }
                    AddLine(position + yOffset * .7f, position + (yOffset * .7f + zOffset * .7f) / 2,
                            lineThickness, drawShadowsFactor);
                    AddLine(position + yOffset * .5f, position + (yOffset * .5f + zOffset * .5f) / 2,
                            lineThickness, drawShadowsFactor);

                    //Z
                    if (!drawShadows)
                    {
                        DebugGeometry.SetColor((axes.z && axes.TrueCount != 3) ? yellow : blue, false);                            //, true );
                    }
                    AddLine(position, position + zOffset,
                            lineThickness, drawShadowsFactor);
                    AddSphere(new Sphere(position + zOffset, size / 80), lineThickness, drawShadowsFactor);
                    AddSphere(new Sphere(position + zOffset, size / 40), lineThickness, drawShadowsFactor);

                    if (!drawShadows)
                    {
                        DebugGeometry.SetColor(axes.z && axes.x ? yellow : blue, false);                          //, true );
                    }
                    AddLine(position + zOffset * .7f, position + (zOffset * .7f + xOffset * .7f) / 2,
                            lineThickness, drawShadowsFactor);
                    AddLine(position + zOffset * .5f, position + (zOffset * .5f + xOffset * .5f) / 2,
                            lineThickness, drawShadowsFactor);
                    if (!drawShadows)
                    {
                        DebugGeometry.SetColor(axes.z && axes.y ? yellow : blue, false);                          //, true );
                    }
                    AddLine(position + zOffset * .7f, position + (zOffset * .7f + yOffset * .7f) / 2,
                            lineThickness, drawShadowsFactor);
                    AddLine(position + zOffset * .5f, position + (zOffset * .5f + yOffset * .5f) / 2,
                            lineThickness, drawShadowsFactor);
                }

                //Selected area
                if (axes.TrueCount >= 2)
                {
                    DebugGeometry.SetColor(new ColorValue(1, 1, 0, .4f), false);                        //, true );

                    List <Vector3> vertices = new List <Vector3>();
                    List <int>     indices  = new List <int>();

                    if (axes.TrueCount == 3)
                    {
                        vertices.Add(position + xOffset * .5f);
                        vertices.Add(position + yOffset * .5f);
                        vertices.Add(position + zOffset * .5f);

                        indices.Add(0); indices.Add(1); indices.Add(2);
                    }
                    else
                    {
                        Vector3 offset1;
                        Vector3 offset2;

                        if (axes.x)
                        {
                            offset1 = xOffset;
                            offset2 = axes.y ? yOffset : zOffset;
                        }
                        else
                        {
                            offset1 = yOffset;
                            offset2 = zOffset;
                        }

                        vertices.Add(position + offset1 * .5f);
                        vertices.Add(position + offset1 * .7f);
                        vertices.Add(position + offset2 * .7f);
                        vertices.Add(position + offset2 * .5f);

                        indices.Add(0); indices.Add(1); indices.Add(2);
                        indices.Add(2); indices.Add(3); indices.Add(0);
                    }

                    DebugGeometry.AddTriangles(vertices, indices, Matrix4.Identity, false, false);
                }

                //DebugGeometry.RestoreDefaultDepthSettings();
            }
コード例 #8
0
ファイル: _Custom1Shape.cs プロジェクト: whztt07/SDK
        protected override void OnDebugRender( DebugGeometry debugGeometry,
			ref Mat4 bodyTransform, bool simpleGeometry )
        {
            Bounds localBounds = new Bounds( -halfDimensions, halfDimensions );
            Mat4 t = bodyTransform;
            if( !IsIdentityTransform )
                t *= GetTransform();
            Box box = new Box( localBounds ) * t;
            debugGeometry.AddBox( box );
        }