Ejemplo n.º 1
0
        static void PrintMyShapeList()
        {
            foreach (Shape item in shapes)
            {
                if (item is Triangle)
                {
                    totalTriangleCircumference += (item as Triangle).Circumference;
                }
                if (item is Shape3D)
                {
                    biggestVolume = (item as Shape3D);

                    if ((item as Shape3D).Volume > biggestVolume.Volume)
                    {
                        biggestVolume = (item as Shape3D);
                    }
                }
                Console.WriteLine(item);
                sumOfAllAreas += item.Area;
            }
            var averageArea = sumOfAllAreas / shapes.Count;

            Console.WriteLine($"\n3DFormen med störst volym: {biggestVolume}");
            Console.WriteLine($"Den genomsnittliga arean för alla former: {MathF.Round(averageArea)}");
            Console.WriteLine($"Totala triangelomkretsen: {MathF.Round(totalTriangleCircumference)}");
        }
Ejemplo n.º 2
0
 public PhysicalEntity3D(Shape3D shape, Rational shapeSize, Rational shapeDensity, Location3D location)
 {
     this.shape        = shape;
     this.shapeSize    = shapeSize;
     this.shapeDensity = shapeDensity;
     this.location     = location;
 }
Ejemplo n.º 3
0
        public static void Manage(Shape3D shape3D,
                                  Dictionary <string, Shape3D> shapes3D,
                                  Stack <Shape3D> shapes2Remove)
        {
            // manage lifetime
            shape3D.LifeTime.Count();

            if (shape3D.LifeTime.IsFinish())
            {
                shapes2Remove.Push(shape3D);
                return;
            }

            // manage shape actions queue
            if (shape3D.ShapeActions == null)
            {
                return;
            }
            if (shape3D.ShapeActions.Count == 0)
            {
                return;
            }


            if (shape3D.ShapeActions.Peek().LifeTime.IsFinish())
            {
                shape3D.ShapeActions.Dequeue().Execute(shape3D);
            }
            else
            {
                shape3D.ShapeActions.Peek().Execute(shape3D);
            }
        }
Ejemplo n.º 4
0
    public List <Shape3D> GenerateFractal(Shape3D shape, List <int[]> buildFaces, int endpt)
    {
        FractalShape origin = new FractalShape
        {
            shape      = shape,
            buildFaces = buildFaces,
            endpt      = endpt,
            depth      = 0,
        };
        List <FractalShape> unhandledChildren = new List <FractalShape> {
            origin
        };
        List <Shape3D> shapes = new List <Shape3D>();

        while (unhandledChildren.Count > 0)
        {
            List <FractalShape> newChildren = GetChildren(unhandledChildren[0]);
            unhandledChildren.AddRange(newChildren);
            foreach (FractalShape f in newChildren)
            {
                shapes.Add(f.shape);
            }

            unhandledChildren.RemoveAt(0);

            while (unhandledChildren.Count > 0 && unhandledChildren[0].depth > 3)
            {
                unhandledChildren.RemoveAt(0);
            }
        }
        return(shapes);
    }
Ejemplo n.º 5
0
        /// <summary>
        /// User selected the plugin, so execute it
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void _menuItem_Click(object sender, EventArgs e)
        {
            //create new groupaction
            GroupAction actions = new GroupAction("Rename Textlabel");

            int i = 0;

            //search for shapes in layer (do not search recursively)
            foreach (Layer layer in EditorManager.Scene.Layers)
            {
                foreach (ShapeBase shape in layer.Root.ChildCollection)
                {
                    Shape3D shape3d = shape as Shape3D;
                    if (shape3d == null || !shape3d.Modifiable)
                    {
                        continue;
                    }
                    actions.Add(new SetPropertyAction(shape3d, "TextLabel", "Object" + i));
                    i++;
                }
            }

            // spawn an undoable action. To trigger it silently, just call actions.Do();
            if (actions.Valid)
            {
                EditorManager.Actions.Add(actions);
            }
        }
Ejemplo n.º 6
0
    public void Start()
    {
        isSpiky = true;
        //0.5% spiky
        if (isSpiky)
        {
            normalfactor = UnityEngine.Random.Range(normalfactorSpikyRangeLow, normalfactorSpikyRangeHigh);
            minsize      = 200;
            maxsize      = 300;
            numpts       = UnityEngine.Random.Range(3, 5);
        }
        //99.5% plate
        else
        {
            normalfactor = UnityEngine.Random.Range(normalfactorRangeLow, normalfactorRangeHigh);
            minsize      = 35;
            maxsize      = 45;
        }
        List <int[]> buildFaces = new List <int[]>();
        int          endPt      = -1;
        Shape3D      s          = BuildSeed(transform.position, minsize, maxsize, numpts, out buildFaces, out endPt);

        GetComponent <ShapeBuilder3D>().Initialize(s.points.ToArray(), s.triangles);

        if (isSpiky)
        {
            List <Shape3D> children = GenerateFractal(s, buildFaces, endPt);
            foreach (Shape3D shape in children)
            {
                GameObject     g  = Instantiate(fractalChild, transform.position, Quaternion.identity, transform);
                ShapeBuilder3D sh = g.GetComponent <ShapeBuilder3D>();
                sh.Initialize(shape.points.ToArray(), shape.triangles);
            }
        }
    }
Ejemplo n.º 7
0
    void Start()
    {
        // force it to Landscape on mobile (can be set in the Player Settings, too)
        Screen.orientation = ScreenOrientation.Landscape;

        // procedurally build the sphere mesh (for 3D Displacement)
        sphereMesh = Shape3D.CreateSphereMesh(0.5f, 100, 100); // highly tessellated sphere
        //sphereMesh = Shape3D.CreateSphereMesh(0.5f, 10, 10); // low poly sphere

        // use the sphere mesh built-in to Unity
        //GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
        //sphereMesh = sphere.GetComponent<MeshFilter>().mesh;
        //GameObject.DestroyImmediate(sphere);

        // build the mesh (full screen quad) in clip-space (for 2D Animation)
        quadMesh           = new Mesh();
        quadMesh.vertices  = new Vector3[] { new Vector3(-1, 1), new Vector3(1, 1), new Vector3(-1, -1), new Vector3(1, -1) };
        quadMesh.uv        = new Vector2[] { new Vector2(0, 1), new Vector2(1, 1), new Vector2(0, 0), new Vector2(1, 0) };
        quadMesh.triangles = new int[] { 0, 1, 2, 1, 3, 2 };

        // if not on Windows, default to use the GLSL version of noise
        if (!SystemInfo.operatingSystem.ToLower().Contains("windows"))
        {
            Debug.Log("Detected " + SystemInfo.operatingSystem + ". Using GLSL...");
            useGLSL = true;
        }
        else
        {
            Debug.Log("Detected " + SystemInfo.operatingSystem + ". Using Cg...");
        }
    }
Ejemplo n.º 8
0
 private void SetAppearance(Shape3D shape, AppearanceNode appearance)
 {
     shape.Material.DiffuseColor = TestConvColor(((MaterialNode)appearance.material.node).diffuseColor);
     shape.Material.SpecularColor = TestConvColor(((MaterialNode)appearance.material.node).specularColor);
     shape.Material.AmbientIntensity = ((MaterialNode)appearance.material.node).ambientIntensity.value;
     shape.Material.Shininess = ((MaterialNode)appearance.material.node).shininess.value;
     shape.Material.EmmisiveColor = TestConvColor(((MaterialNode)appearance.material.node).emissiveColor);
 }
Ejemplo n.º 9
0
 public void MyPaint(object sender, PaintEventArgs e)
 {
     t1.Text      = "X speed: " + changex.ToString();
     t2.Text      = "Y speed: " + changey.ToString();
     t3.Text      = "Z speed: " + changez.ToString();
     currentShape = currentShape.Rotate(Zmat).Rotate(Xmat).Rotate(Ymat);
     currentShape.Draw(e.Graphics);
 }
Ejemplo n.º 10
0
 public UIElement GetElement(Shape3D shape)
 {
     if (_getElement != null)
     {
         return(_getElement(shape));
     }
     return(null);
 }
Ejemplo n.º 11
0
 public Material GetMaterial(Shape3D shape)
 {
     if (_getMaterial != null)
     {
         return(_getMaterial(shape));
     }
     return(null);
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="shapes"></param>
 /// <param name="mode"></param>
 /// <param name="includeShapes"></param>
 public DropToFloorAction(ShapeCollection shapes, Shape3D.DropToFloorMode mode, Vector3F axis, bool includeShapes)
     : base("Drop to Floor")
 {
     _shapes = shapes;
       _mode = mode;
       _axis = axis;
       _includeShapes = includeShapes;
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Alternative constructor that takes a single shape
 /// </summary>
 /// <param name="shape"></param>
 /// <param name="mode"></param>
 /// <param name="axis"></param>
 /// <param name="includeShapes"></param>
 public DropToFloorAction(Shape3D shape, Shape3D.DropToFloorMode mode, Vector3F axis, bool includeShapes)
     : base("Drop to Floor")
 {
     _shapes = new ShapeCollection();
     _shapes.Add(shape);
     _mode          = mode;
     _axis          = axis;
     _includeShapes = includeShapes;
 }
Ejemplo n.º 14
0
 public ObjectPrototype(Shape3D shape, MaterialPrototype material, Vector3D position, Vector3D scale,
                        Matrix3D rotation)
 {
     Shape             = shape;
     MaterialPrototype = material;
     Position          = position;
     Scale             = scale;
     Rotation          = rotation;
 }
Ejemplo n.º 15
0
        static void Main(string[] args)
        {
            //Gör så att det blir punkter mellan koordinaterna som i lab2pdf exemplet.
            CultureInfo.CurrentCulture = new CultureInfo("en-US", false);

            //Skapar lista för alla 20 random shapes
            var shapegen = new List <Shape>();

            //Sätter den till null för att instantiera den.
            Shape3D myshape = null;

            float triangelCircumferenceSum = 0, totalArea = 0;

            //Loopar 20 random shapes som läggs till i listan
            for (var i = 0; i < 20; i++)
            {
                //Lägger till den slumpade shapen i listan med slumpade värden beroendes på vilken metod, i det här fallet med inmatad center position
                shapegen.Add(Shape.GenerateShape(new Vector3(3.0f, 3.0f, 4.0f)));
            }

            //Kollar varje loop för Triangel eller om det är en Shape3D
            foreach (var shape in shapegen)
            {
                if (shape is Triangle)
                {
                    var t = (Triangle)shape;
                    triangelCircumferenceSum += t.Circumference;
                }

                if (shape is Shape3D)
                {
                    //om den inte har instansierat till en shape så sätts den till den första den hittar i loopen som matchar Shape3D
                    if (myshape == null)
                    {
                        myshape = (Shape3D)shape;
                    }

                    //Skapar en Shape3D variabel som sedan används för att alltid få högsta Volym värdet samt vilken instans
                    var k = (Shape3D)shape;

                    if (k.Volume > myshape.Volume)
                    {
                        myshape = k;
                    }
                }

                Console.WriteLine($"{shape}");
                totalArea += shape.Area;
            }

            Console.WriteLine($"\nTotal circumference of triangles: {triangelCircumferenceSum:0.0}");
            Console.WriteLine($"Average area of all shapes: {totalArea / 20:0.0}");
            Console.WriteLine(
                $"The 3D Shape with the largest volume is {myshape}\nwith the volume of: {myshape.Volume:0.0}");
            Console.ReadKey();
        }
Ejemplo n.º 16
0
        private static void Main(string[] args)
        {
            Shape3D volumeShape3D = null;
            float   circumference = 0;
            double  area          = 0;
            float   volume        = 0;
            var     center        = new Vector3(3.00f, 4.00f, 3.00f);
            var     triangle      = new Triangle(new Vector2(3.0f, 4.0f), new Vector2(5.0f, 6.0f), new Vector2(8.0f, 3.0f));

            var shapeList = new List <Shape>(20);

            for (var i = 0; i < 20; i++)
            {
                shapeList.Add(Shape.GenerateShape(center));
            }

            foreach (var shape in shapeList)
            {
                Console.WriteLine(shape);
            }

            foreach (var shape in shapeList)
            {
                if (shape is Triangle t)
                {
                    circumference += t.Circumference;
                }
            }

            foreach (var shape in shapeList)
            {
                area += Convert.ToInt64(shape.Area);
            }

            foreach (var shape in shapeList)
            {
                if (shape is Shape3D s && volume < s.Volume)
                {
                    volume        = s.Volume;
                    volumeShape3D = shape as Shape3D;
                }
            }


            Console.WriteLine($"The average Area of all shapes in the list is {area / shapeList.Count:0.00}");
            Console.WriteLine($"The total of all circumference of all triangles in the list is {circumference:0.00}");
            Console.WriteLine(
                volumeShape3D != null
                    ? $"The shape with the largest volume in the list is a {volumeShape3D.Name} with the volume {volume:0.00} and these parameters: \"{volumeShape3D}\""
                    : "We usually write out the volume of the biggest shape here but there were no 3D shapes created");
            Console.WriteLine("The points of the triangle are at these coordinates: ");
            foreach (var point in triangle)
            {
                Console.Write($" {point} ");
            }
        }
Ejemplo n.º 17
0
        public static ObjectPrototype ReadFromFile(BinaryReader br)
        {
            var shape    = Shape3D.ReadShapeFromFile(br);
            var material = new BasicMaterial(br);
            var position = br.ReadVector3D();
            var scale    = br.ReadVector3D();
            var rotation = br.ReadMatrix3D();

            return(new ObjectPrototype(shape, material, position, scale, rotation));
        }
Ejemplo n.º 18
0
 public ObjectPrototype(Shape3D shape, MaterialPrototype material, Vector3D position, Vector3D scale,
                        double azimuthal = 0, double polar = 0)
 {
     Shape             = shape;
     MaterialPrototype = material;
     Position          = position;
     Scale             = scale;
     AzimuthalAngle    = azimuthal;
     PolarAngle        = polar;
 }
Ejemplo n.º 19
0
        /// <summary> Draw the result as a product. </summary>
        ///
        /// <param name="result">The result to draw as a product.</param>
        private void DrawProduct(Result result)
        {
            var shape = new Shape3D(FormType.Box)
            {
                Length  = result.ExternalLength,
                Breadth = result.ExternalBreadth,
                Height  = result.ExternalHeight
            };

            this.drawing.Shapes.Add(shape);
        }
Ejemplo n.º 20
0
        static public void Main(string[] args)
        {
            float   triangleCircumferenceSum = 0;
            float   averageArea        = 0;
            float   greatestVolume     = 0;
            Shape3D greatestVolumeItem = null;

            List <Shape> randomShapesList    = new List <Shape>();
            int          count               = 1;
            int          greatestVolumeCount = 0;

            for (int i = 0; i < 20; i++)
            {
                randomShapesList.Add(Shape.GenerateShape());
            }
            foreach (Shape this_Shape in randomShapesList)
            {
                if (this_Shape is Triangle this_Triangle)
                {
                    triangleCircumferenceSum += this_Triangle.Circumference;
                }
                if (this_Shape is Shape3D this_Shape3D)
                {
                    if (this_Shape3D.Volume > greatestVolume)
                    {
                        greatestVolumeItem  = this_Shape3D;
                        greatestVolume      = this_Shape3D.Volume;
                        greatestVolumeCount = count;
                    }
                }
                Console.WriteLine($"{count}: {this_Shape}");
                averageArea += this_Shape.Area;
                count++;
            }

            Console.WriteLine("- - - - - - - - - - - - - - - - -");
            Console.WriteLine();
            Console.WriteLine("Calculations");
            Console.WriteLine($"The sum for the circumference of all the triangles is: {triangleCircumferenceSum}cm");
            Console.WriteLine($"The average area of all the shapes is: {averageArea/randomShapesList.Count}cm2");
            Console.WriteLine($"Item [{greatestVolumeCount}: {greatestVolumeItem}] has the greatest volume of: {greatestVolume}cm³");


            //VG
            Triangle t = new Triangle(Vector2.Zero, Vector2.One, new Vector2(2.0f, 0.5f));

            Console.WriteLine("- - - - - - - - - - - - - - - - -");
            Console.WriteLine();
            Console.WriteLine("The triangle you created has the following vertices");
            foreach (Vector2 v in t)
            {
                Console.WriteLine($"Vertice {t.position + 1}: {v}");
            }
        }
Ejemplo n.º 21
0
        /// <param name="shape">The shape (geometry) of the object</param>
        /// <param name="material">The material of the object</param>
        public Object3D(Shape3D shape, BasicMaterial material)
        {
            this.Shape = shape;
            Material   = material;

            // Create transformation
            var transGroup = new Transform3DGroup();

            transGroup.Children.Add(scale);
            transGroup.Children.Add(rotation);
            transGroup.Children.Add(translation);
        }
Ejemplo n.º 22
0
        void PerformScalingTest(Shape3D parent)
        {
            Shape3D  child = (Shape3D)parent.ChildCollection[0];
            Vector3F pos   = child.Position;

            // modify scaling
            parent.UniformScaling = 3.0f;

            // now children should be affected as well
            Assert.AreEqual(child.UniformScaling, parent.UniformScaling, "Children must be affected by scaling");
            Assert.IsFalse(child.Position == pos, "Position must have changed through scaling");
        }
Ejemplo n.º 23
0
        private void Draw(Shape3D shape)
        {
            var p = shape.Position;

            switch (shape.ShapeType)
            {
            case ShapeTypes3D.Box: primitives.Draw((Box)shape, Color.Cyan);
                break;

            case ShapeTypes3D.Cylinder: primitives.Draw((Cylinder)shape, Color.Cyan);
                break;
            }
        }
Ejemplo n.º 24
0
        public ObjectPrototype(Shape3D shape, BasicMaterial material, Vector3D position, Vector3D scale,
                               Matrix3D rotation)
        {
            if (!position.IsValid() || !scale.IsValid())
            {
                throw new ArgumentException("Infinity or not-a-number passed into ObjectPrototype!");
            }

            Shape    = shape;
            Material = material;
            Position = position;
            Scale    = scale;
            Rotation = rotation;
        }
Ejemplo n.º 25
0
        public static void gatherGeometricShapes(ref ShapeCollection shapesOut, ref int numEntitiesOut, ref int numStaticMeshesOut, ref int numTerrainsOut, ref int numCarversOut, ref int numSeedPointsOut, ref int numLocalSettingsOut)
        {
            // Grab all shapes from all layers
            foreach (Layer layer in EditorManager.Scene.Layers)
            {
                if (layer.GetIncludeInNavMesh())
                {
                    recursivelyAddShapes(layer.Root.ChildCollection, ref shapesOut);
                }
            }

            // calculate some statistics
            foreach (ShapeBase shape in shapesOut)
            {
                // check if the shape to be added is in the same zone as the HavokNavMeshShape's parentZone
                // note that if HavokNavMeshShape is not in a zone, then it will only include other shapes that aren't in zones also.

                Shape3D shape3d             = shape as Shape3D;
                Shape3D.eNavMeshUsage usage = shape3d.GetNavMeshUsage();
                if (usage != Shape3D.eNavMeshUsage.ExcludeFromNavMesh)
                {
                    if (shape is EntityShape)
                    {
                        numEntitiesOut++;
                    }
                    else if (shape is StaticMeshShape)
                    {
                        numStaticMeshesOut++;
                    }
                    else if (shape is TerrainShape)
                    {
                        numTerrainsOut++;
                    }
                }
            }

            ShapeCollection carvers = EditorManager.Scene.AllShapesOfType(typeof(HavokNavMeshCarverShape));

            numCarversOut = carvers.Count;

            ShapeCollection seedPoints = EditorManager.Scene.AllShapesOfType(typeof(HavokNavMeshSeedPointShape));

            numSeedPointsOut = seedPoints.Count;

            // Add local settings
            ShapeCollection localSettings = EditorManager.Scene.AllShapesOfType(typeof(HavokNavMeshLocalSettingsShape));

            numLocalSettingsOut = localSettings.Count;
        }
Ejemplo n.º 26
0
        protected Sensor(SensorTypes type, object owner, int groups, int affects, bool isCompound,
                         Shape3D shape = null)
        {
            Debug.Assert(owner != null, "Owner can't be null.");

            this.shape = shape;

            Type       = type;
            Groups     = groups;
            Affects    = affects;
            Owner      = owner;
            IsEnabled  = true;
            IsCompound = isCompound;
            Contacts   = new List <Sensor>();
        }
Ejemplo n.º 27
0
        //private AxisAngleRotation3D thetaRotation = new AxisAngleRotation3D();
        //private AxisAngleRotation3D phiRotation = new AxisAngleRotation3D(new Vector3D(0, 0, 1), 0);

        /// <param name="shape">The shape (geometry) of the object</param>
        /// <param name="material">The material of the object</param>
        public Object3D(Shape3D shape, Material material)
        {
            this.shape = shape;

            // Create transformation
            var transGroup = new Transform3DGroup();

            transGroup.Children.Add(scale);
            transGroup.Children.Add(rotation);
            transGroup.Children.Add(translation);

            // Create geometry model
            GeoModel = new GeometryModel3D(shape.Mesh, material)
            {
                Transform = transGroup
            };
        }
Ejemplo n.º 28
0
        protected REFlatShape(Shape3D origin, Vector3D a, Vector3D ba, Vector3D ca)
            : base(origin) {
            _a = a;
            _ba = ba;
            _ca = ca;
            _b = ba + a;
            _c = ca + a;
            _w = Vector3D.Product(ba, ca);
            float det = Math3D.CalcDet(U.X, V.X, W.X,
                                       U.Y, V.Y, W.Y,
                                       U.Z, V.Z, W.Z);
            _tu = Vector3D.Product(V, W) / det;
            _tv = Vector3D.Product(W, U) / det;
            _tw = Vector3D.Product(U, V) / det;
            _normal = _w.Normalize();

        }
Ejemplo n.º 29
0
        public void InheritScalingTest()
        {
            TestManager.Helpers.OpenSceneFromFile(Path.Combine(TestManager.Helpers.TestDataDir, @"MiscScenes\InheritScaling.scene"));

            ShapeBase cam = EditorManager.Scene.FindShapeByName("CameraPosition");

            if (cam != null)
            {
                cam.OnDoubleClick();
            }
            Shape3D mesh   = (Shape3D)EditorManager.Scene.FindShapeByName("StaticMeshParent");
            Shape3D entity = (Shape3D)EditorManager.Scene.FindShapeByName("EntityParent");

            PerformScalingTest(mesh);
            PerformScalingTest(entity);
            TestManager.Helpers.CloseTestProject();
        }
Ejemplo n.º 30
0
        /// <summary>
        /// overridden function that evaluates the position on the path
        /// </summary>
        public override void EvaluatePosition()
        {
            ShapeCollection vertices = Volume.ChildCollection;

            Shape3D vertex1;

            if (_insert == 0)
            {
                vertex1 = (Shape3D)vertices[vertices.Count - 1];
            }
            else
            {
                vertex1 = (Shape3D)vertices[_insert - 1];
            }
            Shape3D vertex2 = (Shape3D)vertices[_insert];

            Position = (vertex1.Position + vertex2.Position) * 0.5f;
        }
Ejemplo n.º 31
0
        static void Main(string[] args)
        {
            var shapes = new List <Shape>();

            for (int i = 0; i < 20; i++)
            {
                shapes.Add(Shape.GenerateShape());
            }

            float   sumTriangleCircumference = 0;
            Shape3D largestShape3d           = null;
            float   sumShapeArea             = 0;

            foreach (Shape s in shapes)
            {
                Console.WriteLine(s);

                sumShapeArea += s.Area;

                if (s is Triangle triangle)
                {
                    sumTriangleCircumference += triangle.Circumference;
                }

                if (s is Shape3D shape3d && (largestShape3d == null || largestShape3d.Volume < shape3d.Volume))

                {
                    largestShape3d = shape3d;
                }
            }
            if (largestShape3d == null)
            {
                Console.WriteLine("No 3DShape");
            }
            else
            {
                Console.WriteLine($"\nLargest shape 3d is  = { largestShape3d}");
            }

            Console.WriteLine($"Average Area of the shapes is: {sumShapeArea / shapes.Count}");
            Console.WriteLine($"Sum of triangle circumference = {sumTriangleCircumference}");
            Console.Write("\nPress any key to continue . . .");
            Console.ReadKey();
        }
Ejemplo n.º 32
0
        private static void NewOne()
        {
            //Beter Version
            Dog dog = new Dog("Corgi", 4, "Yes", "Tommy", "DogPhylum", 13, "DogSpecies");

            Console.WriteLine("From Dog Object");
            dog.Eat();
            dog.FeedBabys();
            dog.GiveBirth();
            dog.Bark();
            Console.WriteLine(dog.ToString());
            Console.WriteLine();
            Cat cat = new Cat("Wild", 4, "Yes", "Simba", "BigCat", 8, "CatSpecies");

            Console.WriteLine("From Cat Object");
            cat.Eat();
            cat.FeedBabys();
            cat.GiveBirth();
            cat.Meow();
            cat.Purr();
            Console.WriteLine(cat.ToString());
            Console.WriteLine();

            if (cat.Limbs.Equals(dog.Limbs))
            {
                Console.WriteLine("Inheritance....");
            }
            Console.WriteLine();

            Shape2D shape2D = new Shape2D();

            shape2D.Length  = 10;
            shape2D.Breadth = 20;
            shape2D.Display();
            Console.WriteLine("Area " + shape2D.Area());
            Console.WriteLine();

            Shape3D shape3D = new Shape3D(10, 20, 30);

            shape3D.Display();
            Console.WriteLine("Volume: " + shape3D.Area());
            Console.WriteLine();
        }
Ejemplo n.º 33
0
        /// <summary>
        /// Test whether attaching the childShape to the parentShape works correctly
        /// </summary>
        /// <param name="parentShapeName">name of shapetype used as parent shape</param>
        /// <param name="childShapeName">name of shapetype used as child shape</param>
        protected void PerformShapeParentingTest(string parentShapeName, string childShapeName)
        {
            // create test shapes
            EditorManager.GetShapeCreatorPluginByName(childShapeName).ExecutePlugin();
            EditorManager.GetShapeCreatorPluginByName(parentShapeName).ExecutePlugin();
            Shape3D parentShape = (Shape3D)EditorManager.Scene.ActiveLayer.Root.ChildCollection[1];
            Shape3D childShape  = (Shape3D)EditorManager.Scene.ActiveLayer.Root.ChildCollection[0];

            parentShape.Position   = new Vector3F(100, 100, 100);
            childShape.Position    = new Vector3F(200, 100, 100);
            childShape.Orientation = new Vector3F(0, 0, 0);

            // attach to parent
            childShape.SetParent(parentShape);
            Assert.AreSame(parentShape, childShape.Parent);
            Assert.AreEqual(childShape.Position, new Vector3F(200, 100, 100));
            Assert.AreEqual(childShape.Orientation, new Vector3F(0, 0, 0));

            // verify that child moves when parent moves
            parentShape.x += 100;
            Assert.AreEqual(childShape.Position, new Vector3F(300, 100, 100));

            // test orientation only if supported
            if ((!parentShape.IsHintSet(ShapeBase.HintFlags_e.NoRotation)) && (!childShape.IsHintSet(ShapeBase.HintFlags_e.NoRotation)))
            {
                // verify orientation
                parentShape.Yaw += 90;
                const float ORIENTATION_EPSILON = 0.0001f;
                Assert.AreEqual(childShape.Orientation.X, 90, ORIENTATION_EPSILON);
                Assert.AreEqual(childShape.Orientation.Y, 0, ORIENTATION_EPSILON);
                Assert.AreEqual(childShape.Orientation.Z, 0, ORIENTATION_EPSILON);
            }

            // perform some rendering in-between to proof it does not crash while rendering
            EditorManager.ActiveView.UpdateView(true);

            // cleanup
            EditorManager.Scene.ActiveLayer.RemoveShape(parentShape);
            Assert.AreEqual(0, EditorManager.Scene.ActiveLayer.Root.ChildCollection.Count);

            EditorManager.ActiveView.UpdateView(true);
        }
Ejemplo n.º 34
0
        public BillboardDropToFloorAction(BillboardGroupShape shape, BillboardInstance[] instances, Shape3D.DropToFloorMode mode, Vector3F axis, ShapeCollection colliderShapes)
        {
            _instances = instances;
              if (_instances == null)
            _instances = shape.Instances;

              _shape = shape;
              _mode = mode;
              _oldHeights = new float[_instances.Length];
              _newHeights = new float[_instances.Length];

              for (int i = 0; i < _instances.Length; i++)
            _oldHeights[i] = _instances[i].Z;
              _shape.EngineMesh.GetDropToFloorHeights(_shape, _instances, _mode, axis, colliderShapes);
              for (int i = 0; i < _instances.Length; i++)
            _newHeights[i] = _instances[i].Z;
        }
Ejemplo n.º 35
0
 public override IAction GetCustomDropToFloorAction(Shape3D.DropToFloorMode mode, Vector3F axis, ShapeCollection colliderShapes)
 {
     if (!HasEngineInstance() || Instances.Length < 1)
     return base.GetCustomDropToFloorAction(mode, axis, colliderShapes);
       return new BillboardDropToFloorAction(this, null, mode, axis, colliderShapes); // all instances
 }
 /// <summary>
 /// Constructor that takes the shape to move and the move positions
 /// </summary>
 /// <param name="_shape">The shape to move</param>
 /// <param name="_oldPos">The old position of the shape</param>
 public MoveShapeXAction(Shape3D shape, float shiftXValue)
 {
     _shape = shape;
       _oldPos = _shape.Position;
       _shiftXValue = shiftXValue;
 }
Ejemplo n.º 37
0
        public void AddShape()
        {
            this.Element3DCollection.Add(
                new DraggableGeometryModel3D()
                {
                    Geometry = this.MeshGeometry,
                    Material = this.GreenMaterial,
                    Transform = this.Model2Transform,
                    Instances = new List<Matrix> { 
                        Matrix.Translation(-1,0,0), Matrix.Translation(+1,0,0), 
                        Matrix.Translation(0,-1,0), Matrix.Translation(0,+1,0),
                        Matrix.Translation(0,0,-1), Matrix.Translation(0,0,+1), 
                    },
                });

            var shape = new Shape3D()
            {
                Geometry = this.MeshGeometry,
                Material = this.GreenMaterial,
                Transform = this.Model2Transform,
            };
            this.Shape3DCollection.Add(shape);
        }
Ejemplo n.º 38
0
 public HotSpotPlayButton(Shape3D owner, string bitmapfile, uint iColorNormal, uint iColorHigh, float fSize)
     : base(owner, bitmapfile, iColorNormal, PickType.Square, fSize)
 {
     _iColNrml = iColorNormal;
       _iColHigh = iColorHigh;
 }
Ejemplo n.º 39
0
        void CommonInit(ShapeCollection shapes, Shape3D.DropToFloorMode mode, Vector3F axis, bool includeShapes)
        {
            for (int i=0;i<shapes.Count;i++)
              {
            Shape3D shape = shapes[i] as Shape3D;
            if (shape==null || !shape.Traceable || !shape.Modifiable) continue;

            ShapeCollection colliderShapes = null;
            if (includeShapes)
            {
              colliderShapes = EditorManager.Scene.AllShapesOfType(typeof(Shape3D), true);
              if (colliderShapes.Contains(shape))
            colliderShapes.Remove(shape);
            }

            // use a replacement action? (e.g. billboards rather want to drop every single instance)
            IAction custom = shape.GetCustomDropToFloorAction(mode, axis, colliderShapes);
            if (custom != null)
            {
              this.Add(custom);
              continue;
            }

            float fHeight = EditorApp.ActiveView.EngineManager.GetDropToFloorHeight(shape,mode,axis,colliderShapes);
            if (fHeight==0.0f) continue;
            this.Add(new MoveShapeAction(shape,shape.Position, shape.Position + axis * fHeight));
              }
        }
Ejemplo n.º 40
0
        void PerformScalingTest(Shape3D parent)
        {
            Shape3D child = (Shape3D)parent.ChildCollection[0];
              Vector3F pos = child.Position;

              // modify scaling
              parent.UniformScaling = 3.0f;

              // now children should be affected as well
              Assert.AreEqual(child.UniformScaling, parent.UniformScaling, "Children must be affected by scaling");
              Assert.IsFalse(child.Position == pos, "Position must have changed through scaling");
        }
Ejemplo n.º 41
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="ownerShape"></param>
 /// <param name="primaryStringId"></param>
 public LinkSourceConstraint(Shape3D ownerShape, string primaryStringId)
     : base(ownerShape,"affects",primaryStringId)
 {
 }
        public override void DragLeave()
        {
            if (_instance != null)
              {
            _instance.Dispose();
            _instance = null;
              }

              if (_dummyShape != null)
              {
            _dummyShape.Dispose();
            _dummyShape = null;
              }
              EditorManager.ActiveView.UpdateView(false);
        }
Ejemplo n.º 43
0
 /// <summary>
 /// Helper function
 /// </summary>
 /// <param name="mode"></param>
 private void DoDropToFloor(Shape3D.DropToFloorMode mode, Vector3F axis)
 {
     Cursor = Cursors.WaitCursor;
       ShapeCollection shapes = EditorApp.ActiveView.Gizmo.Shapes;
       EditorManager.Actions.Add(new DropToFloorAction(shapes, mode, axis, true));
       EditorManager.ActiveView.UpdateView(false);
       Cursor = Cursors.Default;
 }
        private void createShape(System.Windows.Forms.DragEventArgs e)
        {
            _assetPaths = CSharpFramework.Contexts.IDropContext.GetAssetPaths(e);
              _assetTypes = CSharpFramework.Contexts.IDropContext.GetAssetTypes(e);
              _assetNames = CSharpFramework.Contexts.IDropContext.GetAssetNames(e);

              Debug.Assert(_assetPaths.Length == _assetTypes.Length && _assetPaths.Length == _assetNames.Length);
              if (_assetPaths.Length == 0)
            return;

              if (_assetTypes[0] == "Model")
              {
            EntityShape entity = new EntityShape(_assetNames[0]);
            entity.EntityClass = "VisBaseEntity_cl";
            entity.ModelFile = _assetPaths[0];
            _dummyShape = entity;
              }
              else if (_assetTypes[0] == "StaticMesh")
              {
            StaticMeshShape staticMesh = new StaticMeshShape(_assetNames[0]);
            staticMesh.MeshFileName = _assetPaths[0];
            _dummyShape = staticMesh;
              }
              else if (_assetTypes[0] == "Prefab")
              {
            PrefabShape prefabShape = new PrefabShape(_assetNames[0]);
            prefabShape.Filename = _assetPaths[0];
            _dummyShape = prefabShape;
              }
        }
 /// <summary>
 /// Default constructor used by the factory class
 /// </summary>
 /// <param name="ownerShape"></param>
 /// <param name="linkName"></param>
 /// <param name="primaryStringId"></param>
 public LinkSourceVisiblity(Shape3D ownerShape, string linkName, string primaryStringId)
   : base(ownerShape, linkName, primaryStringId)
 {
 }
Ejemplo n.º 46
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="ownerShape"></param>
 /// <param name="primaryStringId"></param>
 public LinkSourceGroupStaticMeshes(Shape3D ownerShape, string primaryStringId) : base(ownerShape,"affects",primaryStringId)
 {
 }
 /// <summary>
 /// Standard constructor
 /// </summary>
 /// <param name="owner"></param>
 public LinkSourceHavokConstraint(Shape3D owner)
     : base(owner, "attach to anchor", "LS_HavokConstraint")
 {
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="ownerShape"></param>
 /// <param name="primaryStringId"></param>
 public LinkSourceVisiblity(Shape3D ownerShape, string primaryStringId) : base(ownerShape,"affects",primaryStringId)
 {
 }
 /// <summary>
 /// Default constructor used by the factory class
 /// </summary>
 /// <param name="ownerShape"></param>
 /// <param name="linkName"></param>
 /// <param name="primaryStringId"></param>
 public LinkSourceHavokConstraint(Shape3D ownerShape, string linkName, string primaryStringId)
     : base(ownerShape, linkName, primaryStringId)
 {
 }
Ejemplo n.º 50
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="ownerShape"></param>
 /// <param name="primaryStringId"></param>
 public LinkTargetGroupStaticMeshes(Shape3D ownerShape, string primaryStringId) : base(ownerShape,"visibility determined by",primaryStringId)
 {
 }
Ejemplo n.º 51
0
        public override ShapeLink CreateShapeLink(string classname, Shape3D ownerShape, string name, string primaryID)
        {
            Type t = _cachedClassTypes.ContainsKey(classname) ? _cachedClassTypes[classname] : null;
              if (t == null)
              {
            // loop through all assemblies and find the type by name
            Assembly[] assemblies = AssemblyHelper.GetEditorAssemblies();
            foreach (Assembly assembly in assemblies)
            {
              Type[] types = null;
              try
              {
            types = assembly.GetTypes();
              }
              catch (Exception ex)
              {
            EditorManager.IgnoreException(ex);
              }
              if (types == null)
            continue;

              foreach (Type type in types)
            if (type.Name == classname && type.IsSubclassOf(typeof(ShapeLink)))
            {
              t = type;
              break;
            }
              if (t != null)
            break;
            }
            _cachedClassTypes[classname] = t; // can be null, which is also cached
              }

              if (t == null)
              {
            if (ThrowExceptions)
              throw new Exception("Unknown shape class '" + classname + "'");
            return null;
              }

              string moreFailInfo = "";
              try
              {
            object[] args = new object[3] { ownerShape, name, primaryID }; // always use this constructor
            ShapeLink newObject = Activator.CreateInstance(t, args) as ShapeLink;
            if (newObject == null)
            {
              if (ThrowExceptions)
            throw new Exception("Failed to create instance of class '" + classname + "'");
              return null;
            }
            return newObject;
              }
              catch (Exception ex)
              {
            EditorManager.DumpException(ex, false);
            moreFailInfo = "\nDetailed: ";
            if (ex.InnerException != null)
              moreFailInfo += ex.InnerException.ToString();
            else
              moreFailInfo += ex.Message;
              }

              if (ThrowExceptions)
            throw new Exception("Failed to create instance of class '" + classname + "'" + moreFailInfo);
              return null;
        }
Ejemplo n.º 52
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="ownerShape"></param>
 /// <param name="primaryStringId"></param>
 public LinkTargetConstraint(Shape3D ownerShape, string primaryStringId)
     : base(ownerShape,"affected by",primaryStringId)
 {
 }
Ejemplo n.º 53
0
 public BidirectionalNodeLink(Shape3D ownerShape)
     : base(ownerShape,"links to", "NodeSource_1")
 {
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="ownerShape"></param>
 /// <param name="primaryStringId"></param>
 public LinkTargetVisiblity(Shape3D ownerShape, string primaryStringId) : base(ownerShape,"visibility determined by",primaryStringId)
 {
 }
Ejemplo n.º 55
0
 public DropToFloorPivotAction(Shape3D shape, Vector3F axis, bool includeShapes)
     : base(shape, Shape3D.DropToFloorMode.Pivot, axis, includeShapes)
 {
 }
 public DecorationModelResource(Shape3D terrain, int iID)
 {
     _ownerTerrain = terrain;
       ID = iID;
 }
 public DetailTextureResource(Shape3D ownerTerrain, int iID)
 {
     _ownerTerrain = ownerTerrain;
       ID = iID;
 }
Ejemplo n.º 58
0
 /// <summary>
 /// Default constructor used by the factory class
 /// </summary>
 /// <param name="ownerShape"></param>
 /// <param name="linkName"></param>
 /// <param name="primaryStringId"></param>
 public LinkSourceGroupStaticMeshes(Shape3D ownerShape, string linkName, string primaryStringId)
   : base(ownerShape, linkName, primaryStringId)
 {
 }
Ejemplo n.º 59
0
 /// <summary>
 /// Default constructor used by the factory class
 /// </summary>
 /// <param name="ownerShape"></param>
 /// <param name="linkName"></param>
 /// <param name="primaryStringId"></param>
 public LinkTargetConstraint(Shape3D ownerShape, string linkName, string primaryStringId)
     : base(ownerShape, linkName, primaryStringId)
 {
 }
Ejemplo n.º 60
0
 /// <summary>
 /// Default constructor used by the factory class
 /// </summary>
 /// <param name="ownerShape"></param>
 /// <param name="linkName"></param>
 /// <param name="primaryStringId"></param>
 public LinkTargetPath(Shape3D ownerShape, string linkName, string primaryStringId)
     : base(ownerShape, linkName, primaryStringId)
 {
     this.iIndex = 0; // -1 would discard this in the entity. We don't need the index here
 }