public FruitRenderer(ICoreClientAPI capi, Item item) { this.capi = capi; this.id = nextID++; CompositeShape shapeLoc = item.Shape; if (item.Attributes != null && item.Attributes["onGround"].AsBool(false)) { onGround = true; } AssetLocation loc = shapeLoc.Base.Clone().WithPathPrefixOnce("shapes/").WithPathAppendixOnce(".json"); Shape shape = capi.Assets.TryGet(loc).ToObject <Shape>(); Vec3f rot = new Vec3f(shapeLoc.rotateX, shapeLoc.rotateY, shapeLoc.rotateZ); capi.Tesselator.TesselateShape(item, shape, out itemMesh, rot, null, shapeLoc.SelectiveElements); //itemMesh.SetVertexFlags(0x8000800); itemMesh.CustomFloats = matrixAndLightFloats = new CustomMeshDataPartFloat((16 + 4) * 10100) { Instanced = true, InterleaveOffsets = new int[] { 0, 16, 32, 48, 64 }, InterleaveSizes = new int[] { 4, 4, 4, 4, 4 }, InterleaveStride = 16 + 4 * 16, StaticDraw = false, }; itemMesh.CustomFloats.SetAllocationSize((16 + 4) * 10100); meshref = capi.Render.UploadMesh(itemMesh); }
public void Clone() { CompositeShape compositeShape = new CompositeShape(); for (int i = 0; i < 10; i++) { Pose pose = new Pose(new Vector3(i, i, i)); PointShape point = new PointShape(i, i, i); GeometricObject geometry = new GeometricObject(point, pose); compositeShape.Children.Add(geometry); } CompositeShape clone = compositeShape.Clone() as CompositeShape; Assert.IsNotNull(clone); Assert.AreEqual(10, clone.Children.Count); for (int i = 0; i < 10; i++) { Assert.IsNotNull(clone.Children[i]); Assert.AreNotSame(compositeShape.Children[i], clone.Children[i]); Assert.IsTrue(clone.Children[i] is GeometricObject); Assert.AreEqual(compositeShape.Children[i].Pose, clone.Children[i].Pose); Assert.IsNotNull(clone.Children[i].Shape); Assert.AreNotSame(compositeShape.Children[i].Shape, clone.Children[i].Shape); Assert.IsTrue(clone.Children[i].Shape is PointShape); Assert.AreEqual(((PointShape)compositeShape.Children[i].Shape).Position, ((PointShape)clone.Children[i].Shape).Position); } Assert.AreEqual(compositeShape.GetAabb(Pose.Identity).Minimum, clone.GetAabb(Pose.Identity).Minimum); Assert.AreEqual(compositeShape.GetAabb(Pose.Identity).Maximum, clone.GetAabb(Pose.Identity).Maximum); }
protected override CompositeShape GetShape() { CompositeShape shape = Block.Shape.Clone(); shape.Base = new AssetLocation("shapes/block/metal/mechanics/creativerotor-spinbar.json"); return(shape); }
public MeshRef GetOrCreateMealMeshRef(CompositeShape containerShape, CookingRecipe forRecipe, ItemStack[] contentStacks, Vec3f foodTranslate = null) { Dictionary <int, MeshRef> meshrefs = null; object obj; if (capi.ObjectCache.TryGetValue("cookedMeshRefs", out obj)) { meshrefs = obj as Dictionary <int, MeshRef>; } else { capi.ObjectCache["cookedMeshRefs"] = meshrefs = new Dictionary <int, MeshRef>(); } if (contentStacks == null) { return(null); } int mealhashcode = GetMealHashCode(containerShape, capi.World, contentStacks); MeshRef mealMeshRef = null; if (!meshrefs.TryGetValue(mealhashcode, out mealMeshRef)) { meshrefs[mealhashcode] = mealMeshRef = capi.Render.UploadMesh(CreateMealMesh(containerShape, forRecipe, contentStacks, foodTranslate)); } return(mealMeshRef); }
/// <summary> /// Mouse up function. /// </summary> /// <param name="document">Informations transferred from DrawingPanel.</param> /// <param name="e">MouseEventArgs.</param> public override void MouseUp(IDocument document, MouseEventArgs e) { this.CurrentDocument = document; MousePressed = false; this.isAnnotationActive = false; Points.Add(e.Location); m_colpathType.Add(byte.Parse("0")); mcolTempPoint.Add(e.Location); IShape shape = CreateDrawingShape(e.Location, mcolTempPoint); mcolTempPoint.Clear(); if (shape == null) { return; } if (this.group == null)//Added by rm { this.group = new CompositeShape(); } this.group.Shapes.Add(shape);//Added by rm this.group.Appearance = shape.Appearance; if (!document.Shapes.Contains(group) && group != null) //Added by rm { document.Shapes.Add(group); //Added by rm } Points.Clear(); }
public void Clone() { CompositeShape compositeShape = new CompositeShape(); for (int i = 0; i < 10; i++) { Pose pose = new Pose(new Vector3F(i, i, i)); PointShape point = new PointShape(i, i, i); GeometricObject geometry = new GeometricObject(point, pose); compositeShape.Children.Add(geometry); } CompositeShape clone = compositeShape.Clone() as CompositeShape; Assert.IsNotNull(clone); Assert.AreEqual(10, clone.Children.Count); for (int i = 0; i < 10; i++) { Assert.IsNotNull(clone.Children[i]); Assert.AreNotSame(compositeShape.Children[i], clone.Children[i]); Assert.IsTrue(clone.Children[i] is GeometricObject); Assert.AreEqual(compositeShape.Children[i].Pose, clone.Children[i].Pose); Assert.IsNotNull(clone.Children[i].Shape); Assert.AreNotSame(compositeShape.Children[i].Shape, clone.Children[i].Shape); Assert.IsTrue(clone.Children[i].Shape is PointShape); Assert.AreEqual(((PointShape)compositeShape.Children[i].Shape).Position, ((PointShape)clone.Children[i].Shape).Position); } Assert.AreEqual(compositeShape.GetAabb(Pose.Identity).Minimum, clone.GetAabb(Pose.Identity).Minimum); Assert.AreEqual(compositeShape.GetAabb(Pose.Identity).Maximum, clone.GetAabb(Pose.Identity).Maximum); }
public void AddCompositeToSelf() { var c = new CompositeShape(); Assert.That(() => c.Add(c), Throws.TypeOf <ShapeException>() .With.Message.EqualTo("You cant add a shape to itself")); }
public void CompositeShapeWithRotatedChildren() { var s = new CompositeShape(); s.Children.Add(new GeometricObject(new BoxShape(1, 2, 3), new Vector3F(1.1f, 0.3f, 0.8f), new Pose(new Vector3F(100, 10, 0), RandomHelper.Random.NextQuaternionF()))); s.Children.Add(new GeometricObject(new ConeShape(1, 2), new Vector3F(1.1f, 0.3f, 0.8f), new Pose(new Vector3F(-10, -10, 0), RandomHelper.Random.NextQuaternionF()))); float m0; Vector3F com0; Matrix33F i0; MassHelper.GetMass(s, new Vector3F(2), 1, true, 0.001f, 10, out m0, out com0, out i0); var m = s.GetMesh(0.001f, 6); m.Transform(Matrix44F.CreateScale(2)); float m1; Vector3F com1; Matrix33F i1; MassHelper.GetMass(m, out m1, out com1, out i1); const float e = 0.01f; Assert.IsTrue(Numeric.AreEqual(m0, m1, e * (1 + m0))); Assert.IsTrue(Vector3F.AreNumericallyEqual(com0, com1, e * (1 + com0.Length))); Assert.IsTrue(Matrix33F.AreNumericallyEqual(i0, i1, e * (1 + i0.Trace))); }
public override void Update(GameTime gameTime) { // If progress has changed significantly, get current decomposition. if (_newProgress - _oldProgress >= 10 || _newProgress > 90 && _newProgress - _oldProgress > 1) { _decomposition = _convexDecomposition.Decomposition; _oldProgress = _newProgress; } var debugRenderer = GraphicsScreen.DebugRenderer; debugRenderer.Clear(); // Draw a wireframe of the model. debugRenderer.DrawModel(_modelNode, Color.White, true, false); // Show current progress. debugRenderer.DrawText("\n\nProgress: " + _newProgress + " %"); // Draw the current convex hulls. if (_decomposition != null) { foreach (var childGeometry in _decomposition.Children) { debugRenderer.DrawObject(childGeometry, GraphicsHelper.GetUniqueColor(childGeometry), false, false); } debugRenderer.DrawText("Number of convex parts: " + _decomposition.Children.Count); } }
/// <summary> /// Deserializes the alloy /// </summary> /// <param name="reader"></param> /// <param name="resolver"></param> public void FromBytes(BinaryReader reader, IWorldAccessor resolver) { Code = reader.ReadString(); Ingredients = new CookingRecipeIngredient[reader.ReadInt32()]; for (int i = 0; i < Ingredients.Length; i++) { Ingredients[i] = new CookingRecipeIngredient(); Ingredients[i].FromBytes(reader, resolver.ClassRegistry); Ingredients[i].Resolve(resolver, "[FromBytes]"); } //NameComponentOrder = reader.ReadIntArray(); if (!reader.ReadBoolean()) { Shape = new CompositeShape() { Base = new AssetLocation(reader.ReadString()) }; } PerishableProps = new TransitionableProperties(); PerishableProps.FromBytes(reader, resolver.ClassRegistry); // CanBeServedInto = new JsonItemStack(); // CanBeServedInto.FromBytes(reader, resolver.ClassRegistry); // CanBeServedInto.Resolve(resolver, "[FromBytes]"); }
/// <summary> /// Mouse up function. /// </summary> /// <param name="document">Informations transferred from DrawingPanel.</param> /// <param name="e">MouseEventArgs.</param> public override void MouseUp(IDocument document, MouseEventArgs e) { MousePressed = false; this.isAnnotationActive = false; IShape shape = CreateDrawingShape(e.Location); if (shape == null) { return; } if (this.group != null) //Added by rm { this.group.Shapes.Add(shape); //Added by rm } else //Added by rm { this.group = new CompositeShape(); group.Appearance = shape.Appearance; this.group.Shapes.Add(shape); } if (!document.Shapes.Contains(group) && group != null) //Added by rm { document.Shapes.Add(group); //Added by rm } Points.Clear(); //base.MouseMove(document, e); document.DrawingControl.Invalidate(); }
/// <summary> /// Ungroup in a single shape all selected shapes. /// </summary> /// <param name="document">Informations transferred from DrawingPanel.</param> public static void Ungroup(IDocument document) { ShapeCollection selectedShapes = Select.GetSelectedShapes(document.Shapes); foreach (IShape shape in selectedShapes) { CompositeShape group = shape as CompositeShape; if (group == null) { continue; } document.Shapes.Remove(group); foreach (IShape grouppedShape in group.Shapes) { grouppedShape.Selected = true; document.Shapes.Add(grouppedShape); } while (group.Shapes.Count != 0) { group.Shapes.RemoveAt(0); } } }
public void CompositeShapeWithRigidBodiesDoesNotSupportScaling() { // The first composite shape does not use rigid bodies. var s = new CompositeShape(); s.Children.Add(new GeometricObject(new BoxShape(1, 2, 3), new Vector3F(1.1f, 0.3f, 0.8f), new Pose(new Vector3F(100, 10, 0), RandomHelper.Random.NextQuaternionF()))); s.Children.Add(new GeometricObject(new ConeShape(1, 2), new Vector3F(1.1f, 0.3f, 0.8f), new Pose(new Vector3F(-10, -10, 0), RandomHelper.Random.NextQuaternionF()))); // The second composite shape uses rigid bodies as children. var r0 = new RigidBody(s.Children[0].Shape); r0.Pose = s.Children[0].Pose; r0.Scale = s.Children[0].Scale; r0.MassFrame = MassFrame.FromShapeAndDensity(r0.Shape, r0.Scale, 0.7f, 0.001f, 10); var r1 = new RigidBody(s.Children[1].Shape); r1.Pose = s.Children[1].Pose; r1.Scale = s.Children[1].Scale; r1.MassFrame = MassFrame.FromShapeAndDensity(r1.Shape, r1.Scale, 0.7f, 0.001f, 10); var s1 = new CompositeShape(); s1.Children.Add(r0); s1.Children.Add(r1); float m1; Vector3F com1; Matrix33F i1; MassHelper.GetMass(s1, new Vector3F(2), // !!! 100, true, 0.001f, 10, out m1, out com1, out i1); }
public void UpdateMeshDisplay() { CompositeShape compShape = new CompositeShape(shapes); Mesh mesh = compShape.GetMesh(); meshFilter.mesh = mesh; meshCollider.sharedMesh = mesh; }
public static void TestShape() { var circle = new Circle(); var square = new Square(); var compositeShape = new CompositeShape(); compositeShape.Add(circle,square); Draw(compositeShape); }
public void RemoveShapeNotInComposite() { var composite = new CompositeShape(); var circle = new Circle(20, 20, 5); Assert.That(() => composite.RemoveShape(circle), Throws.TypeOf <ShapeException>() .With.Message.EqualTo($"{typeof(Circle).Name} is not part of the composite shape.")); }
public void ComputeCollision() { CollisionObject a = new CollisionObject(); CompositeShape compo = new CompositeShape(); compo.Children.Add(new GeometricObject(new SphereShape(2), Pose.Identity)); compo.Children.Add(new GeometricObject(new SphereShape(1), new Pose(new Vector3(0, 3, 0)))); a.GeometricObject = new GeometricObject(compo, Pose.Identity); CollisionObject b = new CollisionObject(new GeometricObject { Shape = new PlaneShape(new Vector3(0, 1, 0), 1), Pose = new Pose(new Vector3(0, -1, 0)), }); ContactSet set; CompositeShapeAlgorithm algo = new CompositeShapeAlgorithm(new CollisionDetection()); set = algo.GetClosestPoints(a, b); Assert.AreEqual(true, algo.HaveContact(a, b)); Assert.AreEqual(true, algo.HaveContact(b, a)); Assert.AreEqual(1, set.Count); Assert.AreEqual(2, set[0].PenetrationDepth); Assert.AreEqual(new Vector3(0, -2, 0), set[0].PositionAWorld); ((GeometricObject)a.GeometricObject).Pose = new Pose(new Vector3(0, 2, 3), a.GeometricObject.Pose.Orientation); set = set.Swapped; algo.UpdateContacts(set, 0); Assert.AreEqual(true, algo.HaveContact(a, b)); Assert.AreEqual(true, algo.HaveContact(b, a)); Assert.AreEqual(1, set.Count); Assert.AreEqual(0, set[0].PenetrationDepth); Assert.AreEqual(new Vector3(0, 0, 3), set[0].PositionBWorld); ((GeometricObject)a.GeometricObject).Pose = new Pose(new Vector3(0, 0, 0), Quaternion.CreateRotationZ(ConstantsF.PiOver2)); set = set.Swapped; // new order: (a, b) algo.UpdateContacts(set, 0); Assert.AreEqual(true, algo.HaveContact(a, b)); Assert.AreEqual(2, set.Count); Assert.IsTrue(Vector3.AreNumericallyEqual(new Vector3(-2, 0, 0), set[0].PositionALocal)); Assert.IsTrue(Vector3.AreNumericallyEqual(new Vector3(-1, 3, 0), set[1].PositionALocal)); Assert.AreEqual(new Vector3(0, -1, 0), set[0].Normal); Assert.AreEqual(new Vector3(0, -1, 0), set[1].Normal); Assert.AreEqual(2, set[0].PenetrationDepth); Assert.IsTrue(Numeric.AreEqual(1, set[1].PenetrationDepth)); algo.UpdateClosestPoints(set, 0); Assert.AreEqual(1, set.Count); ((GeometricObject)a.GeometricObject).Pose = new Pose(new Vector3(0, 2.1f, 0), a.GeometricObject.Pose.Orientation); algo.UpdateContacts(set, 0); Assert.AreEqual(false, algo.HaveContact(a, b)); Assert.AreEqual(0, set.Count); algo.UpdateClosestPoints(set, 0); Assert.AreEqual(1, set.Count); Assert.IsTrue(Vector3.AreNumericallyEqual(new Vector3(-2, 0, 0), set[0].PositionALocal)); Assert.AreEqual(new Vector3(0, -1, 0), set[0].Normal); }
private void CreateCompositeShape() { // Convert islands into CompositeShape with convex children. _decomposition = new CompositeShape(); if (_islands == null) { return; } foreach (var island in _islands) { if (island.Vertices.Length <= 0) { continue; } // ReSharper disable EmptyGeneralCatchClause try { // ----- Get convex hull mesh. DcelMesh convexHullMesh; if (island.ConvexHullBuilder == null) { // Create convex hull from scratch. // Get all vertices of all island triangles. var points = island.Triangles.SelectMany(t => t.Vertices); // Create convex hull. convexHullMesh = GeometryHelper.CreateConvexHull(points, VertexLimit, SkinWidth); } else { // Use existing convex hull. convexHullMesh = island.ConvexHullBuilder.Mesh; if (convexHullMesh.Vertices.Count > VertexLimit || SkinWidth != 0) { convexHullMesh.ModifyConvex(VertexLimit, SkinWidth); } } // ----- Add a ConvexPolyhedron to CompositeShape. if (convexHullMesh.Vertices.Count > 0) { var convexHullPoints = convexHullMesh.Vertices.Select(v => v.Position); var convexPolyhedron = new ConvexPolyhedron(convexHullPoints); var geometricObject = new GeometricObject(convexPolyhedron); _decomposition.Children.Add(geometricObject); } } catch { // Could not generate convex hull. Ignore object. } // ReSharper restore EmptyGeneralCatchClause } }
public static void TestShape() { var circle = new Circle(); var square = new Square(); var compositeShape = new CompositeShape(); compositeShape.Add(circle, square); Draw(compositeShape); }
public void UpdateMeshDisplay() { //if (shapes.Count < 1) { return; } //if (shapes[0].points == null) { return; } //if (shapes[0].points.Count < 1) { return; } CompositeShape compShape = new CompositeShape(shapes); meshFilter.mesh = compShape.GetMesh(); }
public override void VisitCompositeShape(CompositeShape composite) { this.Composites++; foreach (var c in composite.Shapes) { c.Accept(this); } }
public void SetUp() { child0 = new GeometricObject(new CircleShape(3), new Pose(new Vector3(0, 5, 0), Quaternion.CreateRotationX(ConstantsF.PiOver2))); child1 = new GeometricObject(new CircleShape(3), new Pose(new Vector3(0, -5, 0), Quaternion.CreateRotationX(ConstantsF.PiOver2))); cs = new CompositeShape(); cs.Children.Add(child0); cs.Children.Add(child1); }
public void TestValidConstruction() { ShapeFactory sf = new ShapeFactory(); CompositeShape compositeShape = sf.MakeCompositeShape(2, 3); Assert.AreEqual(compositeShape.Center.X, 2); Assert.AreEqual(compositeShape.Center.Y, 3); }
public void TestComputeArea() { ShapeFactory sf = new ShapeFactory(); CompositeShape compositeShape = sf.MakeCompositeShape(2, 3); Assert.AreEqual(compositeShape.ComputeArea(), 0); compositeShape.AddShape(sf.MakeCircle(1, 2, 5)); Assert.AreEqual(78.53975, compositeShape.ComputeArea(), 0.0001); }
public void TestMove() { ShapeFactory sf = new ShapeFactory(); CompositeShape compositeShape = sf.MakeCompositeShape(1, 1); compositeShape.Move(1, 1); Assert.AreEqual(2, compositeShape.Center.X); Assert.AreEqual(2, compositeShape.Center.Y); }
public void TestAddShape() { ShapeFactory sf = new ShapeFactory(); CompositeShape compositeShape = sf.MakeCompositeShape(1, 1); Circle testCircle = sf.MakeCircle(3, 2, 2); compositeShape.AddShape(testCircle); Assert.AreEqual(testCircle, compositeShape.GetShapes()[0]); }
public void TestMethod1() { Shape myRectangle = new Rectangle("Rectangle1", "FusionBlue", 0, 0, 0, 1, 1, 1, 1, 0); Shape myRectangle2 = new Rectangle("Rectangle2", "FusionGreen", 0, 0, 0, 1, 1, 1, 1, 0); Shape p1 = new Point("Point1", "Red", 1, 2); Shape p2 = new Point("Point2", "Blue", 3, 4); Shape2d rect2d = myRectangle; Shape2d rect2d2 = myRectangle2; Shape2d p12d = p1; Shape2d p22d = p2; Shape2d Jumble = new CompositeShape("Jumble", "grey"); Jumble.Add(rect2d); Jumble.Add(p12d); Jumble.Add(p22d); Jumble.Add(rect2d2); List <Shape2d> _myShapes = Jumble.GetMyShapes(); Assert.AreEqual(_myShapes[0].GetData(), rect2d.GetData()); Assert.AreEqual(_myShapes[1].GetData(), p12d.GetData()); Assert.AreEqual(_myShapes[2].GetData(), p22d.GetData()); Assert.AreEqual(_myShapes[3].GetData(), rect2d2.GetData()); Assert.AreEqual(_myShapes.Count, 4); Assert.AreEqual(Jumble.ComputeArea(), 2 * myRectangle.ComputeArea()); Jumble.Add(rect2d); Assert.AreEqual(Jumble.ComputeArea(), 2 * myRectangle.ComputeArea()); Jumble.Remove(rect2d); Assert.AreEqual(_myShapes.Count, 3); Jumble.Remove(rect2d); Assert.AreEqual(_myShapes.Count, 3); Jumble.Remove(p12d); Assert.AreEqual(_myShapes.Count, 2); Jumble.Remove(p22d); Assert.AreEqual(_myShapes.Count, 1); Jumble.Remove(rect2d2); Assert.AreEqual(_myShapes.Count, 0); Jumble.Add(rect2d); //Jumble.Add(rect2d); //Jumble.Add(rect2d); //Jumble.Add(rect2d); //Jumble.Add(rect2d); //Jumble.Add(rect2d); Jumble.Add(p12d); Assert.AreEqual(_myShapes.Count, 2); Jumble.Move(1, 1); Jumble.RemoveAll(); Assert.AreEqual(_myShapes.Count, 0); Jumble.Add(Jumble); Jumble.Add(rect2d); Jumble.Add(p12d); Assert.AreEqual(Jumble.GetData(), "Rectangle1 FusionBlue 1 1 1 2 2 2 2 1 Point1 Red 2 3 "); }
public GroupShapeCommand(Canvas InputCanvas, List <Shape> ListShape) { ActiveCanvas = InputCanvas; AllShape = new List <Shape>(); GroupShape = new CompositeShape(); foreach (Shape SelectedShape in ListShape) { AllShape.Add(SelectedShape); GroupShape.Add(SelectedShape); } }
private int GetMealHashCode(CompositeShape containerShape, IClientWorldAccessor world, ItemStack[] contentStacks) { string s = containerShape.Base.ToShortString(); for (int i = 0; i < contentStacks.Length; i++) { s += contentStacks[i].Collectible.Code.ToShortString(); } return(s.GetHashCode()); }
private CompositeFixture(CompositeShape wrappedCompositeShape, CompositeMaterial wrappedCompositeMaterial, Matrix4x4 realParentPose, FixtureDescriptor descriptor) { _root = false; _realParentPose = realParentPose; _pose = descriptor.Pose; _realPose = GMath.mul(_pose, _realParentPose); UserData = descriptor.UserData; _wrappedCompositeMaterial = wrappedCompositeMaterial; _wrappedCompositeShape = wrappedCompositeShape; FixtureFactory = new CompositeFixtureFixtureFactory(this); }
public void TestRemoveShape() { ShapeFactory sf = new ShapeFactory(); CompositeShape compositeShape = sf.MakeCompositeShape(1, 1); Circle testCircle = sf.MakeCircle(3, 2, 2); compositeShape.AddShape(testCircle); Assert.AreEqual(1, compositeShape.GetShapes().Count); compositeShape.RemoveShape(0); Assert.AreEqual(0, compositeShape.GetShapes().Count); }
public void TestClearShapes() { ShapeFactory sf = new ShapeFactory(); CompositeShape compositeShape = sf.MakeCompositeShape(1, 1); compositeShape.AddShape(sf.MakeCircle(3, 2, 2)); compositeShape.AddShape(sf.MakePoint(1, 1)); Assert.AreEqual(compositeShape.GetShapes().Count, 2); compositeShape.ClearShapes(); Assert.AreEqual(compositeShape.GetShapes().Count, 0); }
public void CloneWithPartition() { CompositeShape compositeShape = new CompositeShape(); for (int i = 0; i < 10; i++) { Pose pose = new Pose(new Vector3F(i, i, i)); PointShape point = new PointShape(i, i, i); GeometricObject geometry = new GeometricObject(point, pose); compositeShape.Children.Add(geometry); } CloneWithPartition(compositeShape, new AabbTree<int>()); CloneWithPartition(compositeShape, new AdaptiveAabbTree<int>()); CloneWithPartition(compositeShape, new CompressedAabbTree()); CloneWithPartition(compositeShape, new DynamicAabbTree<int>()); CloneWithPartition(compositeShape, new SweepAndPruneSpace<int>()); }
public void SetUp() { child0 = new GeometricObject(new CircleShape(3), new Pose(new Vector3F(0, 5, 0), QuaternionF.CreateRotationX(ConstantsF.PiOver2))); child1 = new GeometricObject(new CircleShape(3), new Pose(new Vector3F(0, -5, 0), QuaternionF.CreateRotationX(ConstantsF.PiOver2))); cs = new CompositeShape(); cs.Children.Add(child0); cs.Children.Add(child1); }
private void CloneWithPartition(CompositeShape compositeShape, ISpatialPartition<int> partition) { compositeShape.Partition = partition; CompositeShape clone = compositeShape.Clone() as CompositeShape; Assert.IsNotNull(clone); Assert.AreEqual(10, clone.Children.Count); for (int i = 0; i < 10; i++) { Assert.IsNotNull(clone.Children[i]); Assert.AreNotSame(compositeShape.Children[i], clone.Children[i]); Assert.IsTrue(clone.Children[i] is GeometricObject); Assert.AreEqual(compositeShape.Children[i].Pose, clone.Children[i].Pose); Assert.IsNotNull(clone.Children[i].Shape); Assert.AreNotSame(compositeShape.Children[i].Shape, clone.Children[i].Shape); Assert.IsTrue(clone.Children[i].Shape is PointShape); Assert.AreEqual(((PointShape)compositeShape.Children[i].Shape).Position, ((PointShape)clone.Children[i].Shape).Position); } Assert.IsNotNull(clone.Partition); Assert.IsInstanceOf(partition.GetType(), clone.Partition); Assert.AreEqual(compositeShape.Children.Count, clone.Partition.Count); Assert.AreNotSame(partition, clone.Partition); }