示例#1
0
        public ScalingWidget(Box targetObject)
            : base(3)
        {
            box = targetObject;

            YArrow = new Arrow(ArrowBase, ArrowLength, ArrowLineLength, ArrowLineWidth)
            {
                Name = "YArrow"
            };
            XArrow = new Arrow(ArrowBase, ArrowLength, ArrowLineLength, ArrowLineWidth) {

                Name = "XArrow"
            };
            ZArrow = new Arrow(ArrowBase, ArrowLength, ArrowLineLength, ArrowLineWidth)
            {
                Name = "ZArrow"
            };

            Objects[0] = YArrow;
            Objects[1] = XArrow;
            Objects[2] = ZArrow;

            scaling = targetObject.ScalingValues;

            Material = new PhongMaterial() { DiffuseColor = Color.Yellow, AmbientCoefficient=1f};
            YArrow.PositionV3 = new Vector3(-scaling.X / 2 - ArrowLineWidth / 2, scaling.Y / 2, -scaling.Z / 2 - ArrowLineWidth / 2);
            XArrow.PositionV3 = new Vector3(scaling.X / 2 + ArrowLineWidth / 2, -scaling.Y / 2 + ArrowLineWidth / 2, -scaling.Z / 2 - ArrowLineWidth / 2);
            ZArrow.PositionV3 = new Vector3(-scaling.X / 2 - ArrowLineWidth / 2, -scaling.Y / 2 + ArrowLineWidth / 2, scaling.Z / 2 + ArrowLineWidth / 2);

            //YArrow.PositionV3 = new Vector3(-box.Scaling / 2 - ArrowLineWidth / 2, box.Height / 2, -box.Depth / 2 - ArrowLineWidth / 2);
            //XArrow.PositionV3 = new Vector3(box.Width / 2 + ArrowLineWidth / 2, -box.Height / 2 + ArrowLineWidth / 2, -box.Depth / 2 - ArrowLineWidth / 2);
            //ZArrow.PositionV3 = new Vector3(-box.Width / 2 - ArrowLineWidth / 2, -box.Height / 2 + ArrowLineWidth / 2, box.Depth / 2 + ArrowLineWidth / 2);
        }
示例#2
0
        public AABB3D(Vector3 position, float width, float height, float depth)
            : base(12)
        {
            PositionV3 = position;
            Width = width;
            Height = height;
            Depth = depth;

            //ushort[] indices;
            Vector3 topLeftFront = PositionV3 + new Vector3(-width / 2, height / 2, -depth / 2);
            Vector3 bottomLeftFront = PositionV3 + new Vector3(-width / 2, -height / 2, -depth / 2);
            Vector3 topRightFront = PositionV3 + new Vector3(width / 2, height / 2, -depth / 2);
            Vector3 bottomRightFront = PositionV3 + new Vector3(width / 2, -height / 2, -depth / 2);
            Vector3 topLeftBack = PositionV3 + new Vector3(-width / 2, height / 2, depth / 2);
            Vector3 topRightBack = PositionV3 + new Vector3(width / 2, height / 2, depth / 2);
            Vector3 bottomLeftBack = PositionV3 + new Vector3(-width / 2, -height / 2, depth / 2);
            Vector3 bottomRightBack = PositionV3 + new Vector3(width / 2, -height / 2, depth / 2);
            //Indices = indices;

            Objects[0] = new Box(Midpoint(topLeftFront, topRightFront), topRightFront.X - topLeftFront.X, DefaultThickness, DefaultThickness);
            Objects[1] = new Box(Midpoint(topRightFront, topRightBack), DefaultThickness, DefaultThickness, topRightBack.Z - topRightFront.Z + DefaultThickness);
            Objects[2] = new Box(Midpoint(topRightBack, topLeftBack), topRightBack.X - topLeftBack.X, DefaultThickness, DefaultThickness);
            Objects[3] = new Box(Midpoint(topLeftFront, topLeftBack), DefaultThickness, DefaultThickness, topLeftBack.Z - topLeftFront.Z + DefaultThickness);
            Objects[4] = new Box(Midpoint(topRightBack, bottomRightBack), DefaultThickness, topRightBack.Y - bottomRightBack.Y, DefaultThickness);
            Objects[5] = new Box(Midpoint(topLeftBack, bottomLeftBack), DefaultThickness, topLeftBack.Y - bottomLeftBack.Y, DefaultThickness);
            Objects[6] = new Box(Midpoint(topRightFront, bottomRightFront), DefaultThickness, topRightFront.Y - bottomRightFront.Y, DefaultThickness);
            Objects[7] = new Box(Midpoint(topLeftFront, bottomLeftFront), DefaultThickness, topLeftFront.Y - bottomLeftFront.Y, DefaultThickness);
            Objects[8] = new Box(Midpoint(bottomLeftFront, bottomRightFront), bottomRightFront.X - bottomLeftFront.X, DefaultThickness, DefaultThickness);
            Objects[9] = new Box(Midpoint(bottomRightFront, bottomRightBack), DefaultThickness, DefaultThickness, bottomRightBack.Z - bottomRightFront.Z + DefaultThickness);
            Objects[10] = new Box(Midpoint(bottomRightBack, bottomLeftBack), bottomRightBack.X - bottomLeftBack.X, DefaultThickness, DefaultThickness);
            Objects[11] = new Box(Midpoint(bottomLeftFront, bottomLeftBack), DefaultThickness, DefaultThickness, bottomLeftBack.Z - bottomLeftFront.Z + DefaultThickness);

            Material = new PhongMaterial() { DiffuseColor = Color.Yellow, AmbientCoefficient=1f};
        }
示例#3
0
        public Arrow(float baseWidth, float arrowHeight, float lineLength, float lineWidth)
            : base(2)
        {
            this.arrowRadius = arrowHeight/2;
            float halfLength = (arrowHeight + lineLength) / 2;
            float arrowOffset = halfLength - arrowHeight / 2;//halfLength - arrowHeight;
            float lineOffset = halfLength - arrowHeight - lineLength/2;
            arrowPointerCenter = new Vector3(0, arrowOffset, 0);
            Objects[0] = new Pyramid(baseWidth, arrowHeight, baseWidth) { PositionV3 = arrowPointerCenter };
            Objects[1] = new Box(lineWidth, lineLength, lineWidth) { PositionV3 = new Vector3(0,lineOffset, 0)};
            Material = new PhongMaterial() { DiffuseColor = Color.Yellow, AmbientCoefficient=1f};

            foreach (IRenderable rObject in Objects)
                rObject.Material = Material;
        }
示例#4
0
        public BoundingBox(float width, float height, float depth)
            : base(12)
        {
            Vector3 center = Vector3.Zero;
            Width = width;
            Height = height;
            Depth = depth;

            //ushort[] indices;
            Vector3 topLeftFront = center + new Vector3(-width / 2, height / 2, -depth / 2);
            Vector3 bottomLeftFront = center + new Vector3(-width / 2, -height / 2, -depth / 2);
            Vector3 topRightFront = center + new Vector3(width / 2, height / 2, -depth / 2);
            Vector3 bottomRightFront = center + new Vector3(width / 2, -height / 2, -depth / 2);
            Vector3 topLeftBack = center + new Vector3(-width / 2, height / 2, depth / 2);
            Vector3 topRightBack = center + new Vector3(width / 2, height / 2, depth / 2);
            Vector3 bottomLeftBack = center + new Vector3(-width / 2, -height / 2, depth / 2);
            Vector3 bottomRightBack = center + new Vector3(width / 2, -height / 2, depth / 2);

            Vector3[] vertices = new Vector3[] { topLeftFront, bottomLeftFront, topRightFront, bottomRightFront,
                topLeftBack, topRightBack, bottomLeftBack, bottomRightBack };

            Objects[0] = new Box(topRightFront.X - topLeftFront.X, DefaultThickness, DefaultThickness) { PositionV3 = Midpoint(topLeftFront, topRightFront) };
            Objects[1] = new Box(DefaultThickness, DefaultThickness, topRightBack.Z - topRightFront.Z + DefaultThickness) { PositionV3 = Midpoint(topRightFront, topRightBack) };
            Objects[2] = new Box(topRightBack.X - topLeftBack.X, DefaultThickness, DefaultThickness) { PositionV3 = Midpoint(topRightBack, topLeftBack) };
            Objects[3] = new Box(DefaultThickness, DefaultThickness, topLeftBack.Z - topLeftFront.Z + DefaultThickness) { PositionV3 = Midpoint(topLeftFront, topLeftBack) };
            Objects[4] = new Box(DefaultThickness, topRightBack.Y - bottomRightBack.Y, DefaultThickness) { PositionV3 = Midpoint(topRightBack, bottomRightBack) };
            Objects[5] = new Box(DefaultThickness, topLeftBack.Y - bottomLeftBack.Y, DefaultThickness) { PositionV3 = Midpoint(topLeftBack, bottomLeftBack) };
            Objects[6] = new Box(DefaultThickness, topRightFront.Y - bottomRightFront.Y, DefaultThickness) { PositionV3 = Midpoint(topRightFront, bottomRightFront) };
            Objects[7] = new Box(DefaultThickness, topLeftFront.Y - bottomLeftFront.Y, DefaultThickness) { PositionV3 = Midpoint(topLeftFront, bottomLeftFront) };
            Objects[8] = new Box(bottomRightFront.X - bottomLeftFront.X, DefaultThickness, DefaultThickness) { PositionV3 = Midpoint(bottomLeftFront, bottomRightFront) };
            Objects[9] = new Box(DefaultThickness, DefaultThickness, bottomRightBack.Z - bottomRightFront.Z + DefaultThickness) { PositionV3 = Midpoint(bottomRightFront, bottomRightBack) };
            Objects[10] = new Box(bottomRightBack.X - bottomLeftBack.X, DefaultThickness, DefaultThickness) { PositionV3 = Midpoint(bottomRightBack, bottomLeftBack) };
            Objects[11] = new Box(DefaultThickness, DefaultThickness, bottomLeftBack.Z - bottomLeftFront.Z + DefaultThickness) { PositionV3 = Midpoint(bottomLeftFront, bottomLeftBack) };

            Material = new PhongMaterial() { DiffuseColor = Color.DarkGreen, AmbientCoefficient=1f};
            foreach (IRenderable rObject in Objects)
                rObject.Material = Material;
        }