/// <summary> /// Sets the 3D representation of the kinect camera in the 3D representation of the room /// </summary> /// <param name="devKinect">the representation of the kinect camera of the IGS to get its information of size and /// and position</param> public void SetKinectCamera(DevKinect devKinect) { Point3D center = new Point3D(); HelixToolkit.Wpf.BoxVisual3D addKinect = new HelixToolkit.Wpf.BoxVisual3D(); RotateTransform3D trans = new RotateTransform3D(); AxisAngleRotation3D rotation = new AxisAngleRotation3D(); center.X = devKinect.ball.Center.X; center.Y = devKinect.ball.Center.Y; center.Z = devKinect.ball.Center.Z; addKinect.Center = center; addKinect.Length = 0.38; addKinect.Width = 0.156; addKinect.Height = 0.123; rotation.Axis = (new Vector3D(0, 1, 0)); rotation.Angle = devKinect.roomOrientation; trans.Rotation = rotation; trans.CenterX = center.X; trans.CenterY = center.Y; trans.CenterZ = center.Z; addKinect.Transform = trans; this.kinect = addKinect; mainViewport.Children.Remove(kinect); mainViewport.Children.Add(kinect); }
protected void ExportSimpleModel(Exporter e) { var runner = new CrossThreadTestRunner(); runner.RunInSTA( delegate { Console.WriteLine(Thread.CurrentThread.GetApartmentState()); var vp = new Viewport3D { Camera = CameraHelper.CreateDefaultCamera(), Width = 1280, Height = 720 }; vp.Children.Add(new DefaultLights()); var box = new BoxVisual3D(); box.UpdateModel(); vp.Children.Add(box); e.Export(vp); }); }
public void addBox(Point3D point) { BoxVisual3D box; boxes.TryGetValue(point, out box); if (box != null) { this.Children.Remove(box); boxes.Remove(point); } box= new BoxVisual3D(); box.Center = point; box.Width = 1; box.Height = 1; box.Length= 1; this.Children.Add(box); boxes.Add(point, box); }
internal void AddBox(Point3D? pt) { BoxVisual3D b = new BoxVisual3D(); b.Width = 1; b.Height = 1; b.Length = 1; b.Center = ToLocal((Point3D)pt); this.Children.Add(b); }
BoxVisual3D buildBody() { var body = new BoxVisual3D(); body.Length = bodyCoxaLen; body.Height = bodyCoxaLen * 0.5; body.Width = bodyCoxaLen; body.Center = new Point3D(-body.Height, 0, 0); body.Fill = Brushes.Green; return body; }
private void Add(Point3D p, ModelVisual3D visual) { // Create the box visual on the UI thread var box = new BoxVisual3D { Center = p, Width = 0.8, Height = 0.8, Length = 0.8 }; visual.Children.Add(box); }
/* watch = new Stopwatch(); watch.Start(); world = new World(new CollisionSystemSAP()); world.Gravity = new JVector(0, 0, 0); world.CollisionSystem.CollisionDetected += new CollisionDetectedHandler(CollisionSystem_CollisionDetected); //tester(); integratorThread = new Thread(IntegrationWorker); integratorThread.Start(); this.Closing += MainWindow_Closing; } void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e) { watch.Stop(); integratorThread.Abort(); } private void IntegrationWorker() { while (true) { watch.Restart(); float step = 1.0f / 65; if (step > 1.0f / 100.0f) step = 1.0f / 100.0f; world.Step(step, true); } } void CollisionSystem_CollisionDetected(RigidBody body1, RigidBody body2, JVector point1, JVector point2, JVector normal, float penetration) { Console.WriteLine("CollisionSystem_CollisionDetected"); } */ private void tester() { /* Wiring Brace */ Point3D p0 = new Point3D(-0.849706889491251, -3.41818201148931, -3.45752298819413); Point3D p1 = new Point3D(7.65467623338951, -2.94937570295315, -1.60678487891435); Point3DCollection contours = new Point3DCollection(); contours.Add(p0); contours.Add(p1); BoxVisual3D b = new BoxVisual3D(); b.Center = p0; b.Length = 2; b.Height = 2; b.Width = 2; view1.Children.Add(b); BoxVisual3D b1 = new BoxVisual3D(); b1.Center = p1; b1.Length = 2; b1.Height = 2; b1.Width = 2; view1.Children.Add(b1); TubeVisual3D tube = new TubeVisual3D { Diameter = 1.02, Path = contours, Fill = Brushes.Green }; view1.Children.Add(tube); //Point3D pp = new Point3D(0, 0, 0); //Vector3D mv = Point3D.Subtract(p0, pp); // view1.Children.Add(new RectangleVisual3D { Origin = p0, Normal = mv, Fill = new SolidColorBrush(Color.FromArgb(190, 255, 0, 0)), BackMaterial = MaterialHelper.CreateMaterial(new SolidColorBrush(Colors.Green)) }); //view1.Children.Add(new RectangleVisual3D { Origin = pp, Normal = mv, Fill = new SolidColorBrush(Color.FromArgb(190, 255, 0, 0)), BackMaterial = MaterialHelper.CreateMaterial(new SolidColorBrush(Colors.AliceBlue)) }); /* Normal Vector Directions Point3D p0 = new Point3D(-0.849706889491251,-3.41818201148931,-3.45752298819413); Point3D p1 = new Point3D(7.65467623338951,-2.94937570295315,-1.60678487891435); Point3D p2 = new Point3D(3.58212516465058, 3.19543635742251, -4.13603328982721); BoxVisual3D b = new BoxVisual3D(); b.Center = p0; b.Length = 2; b.Height = 2; b.Width = 2; view1.Children.Add(b); BoxVisual3D b1 = new BoxVisual3D(); b1.Center = p1; b1.Length = 2; b1.Height = 2; b1.Width = 2; view1.Children.Add(b1); BoxVisual3D b2 = new BoxVisual3D(); b2.Center = p2; b2.Length = 2; b2.Height = 2; b2.Width = 2; view1.Children.Add(b2); Vector3D n0 = Point3D.Subtract(p0, p1); n0.Negate(); view1.Children.Add(new RectangleVisual3D { Origin = p0, Normal = n0, Fill = new SolidColorBrush(Color.FromArgb(80, 255, 0, 0)), BackMaterial = MaterialHelper.CreateMaterial(new SolidColorBrush(Colors.Green)) }); Vector3D n1 = Point3D.Subtract(p1, p0); n1.Negate(); view1.Children.Add(new RectangleVisual3D { Origin = p1, Normal = n1, Fill = new SolidColorBrush(Color.FromArgb(100, 255, 0, 0)), BackMaterial = MaterialHelper.CreateMaterial(new SolidColorBrush(Colors.Green)) }); Point3D m = new Point3D(); m.X = (p1.X + p0.X)/2; m.Y = (p1.Y + p0.Y)/2; m.Z = (p1.Z + p0.Z)/2; BoxVisual3D b3 = new BoxVisual3D(); b3.Center = m; b3.Length = 1; b3.Height = 1; b3.Width = 1; view1.Children.Add(b3); Point3D pp = new Point3D(0, 0, 0); Vector3D mv = Point3D.Subtract(p0, pp); view1.Children.Add(new RectangleVisual3D { Origin = pp, Normal = mv, Fill = new SolidColorBrush(Color.FromArgb(190, 255, 0, 0)), BackMaterial = MaterialHelper.CreateMaterial(new SolidColorBrush(Colors.Green)) }); Vector3D n2 = Point3D.Subtract(p2, m); n2.Negate(); view1.Children.Add(new RectangleVisual3D { Origin = p2, Normal = n2, Fill = new SolidColorBrush(Color.FromArgb(190, 255, 0, 0)), BackMaterial = MaterialHelper.CreateMaterial(new SolidColorBrush(Colors.Green)) }); //Vector3D n = CalculateNormal(ref p0, ref p1, ref p2); //view1.Children.Add(new RectangleVisual3D { Origin = p1, Normal = n, Fill = new SolidColorBrush(Color.FromArgb(190, 255, 0, 0)), BackMaterial = MaterialHelper.CreateMaterial(new SolidColorBrush(Colors.Green)) }); */ /* Cutting Plane var mb = new MeshBuilder(); mb.AddSphere(new Point3D(-2, 0, 0), 2); var mesh = mb.ToMesh(); var n = new Vector3D(0, 0.2, 1); var p = new Point3D(0, 0, 0.5); var geo = MeshGeometryHelper.Cut(mesh, p, n); var m = new GeometryModel3D(geo, Materials.Blue); m.BackMaterial = Materials.Red; var mv = new ModelVisual3D(); mv.Content = m; view1.Children.Add(mv); var mbx = new MeshBuilder(); mbx.AddSphere(new Point3D(2, 0, 0), 1); var mvd = new ModelVisual3D(); GeometryModel3D g = new GeometryModel3D(mbx.ToMesh(), Materials.Blue); mvd.Content = g; view1.Children.Add(mvd); var segments = MeshGeometryHelper.GetContourSegments(mesh, p, n).ToList(); foreach (IList<Point3D> contour in MeshGeometryHelper.CombineSegments(segments, 1e-6).ToList()) { if (contour.Count == 0) continue; Point3DCollection contours = new Point3DCollection(contour); view1.Children.Add(new TubeVisual3D { Diameter = 0.02, Path = contours, Fill = Brushes.Green }); } view1.Children.Add(new RectangleVisual3D { Origin = p, Normal = n, Fill = new SolidColorBrush(Color.FromArgb(80, 255, 0, 0)) }); */ /* g = new SmileVisual3D(); GeometryModel3D geo1 = GeometryGenerator.CreateCubeModel(); geo1.Material = new DiffuseMaterial(new SolidColorBrush(Colors.Red)); Transform3DGroup transformGroup = new Transform3DGroup(); transformGroup.Children.Add(new ScaleTransform3D(2, 2, 2)); g.Transform = transformGroup; g.Content =geo1; view1.Children.Add(g); CombinedManipulator c = new CombinedManipulator(); //c.Diameter = 5; c.Bind(g); view1.Children.Add(c); */ /* List<Point3d> pointList = // list of candidate points Point3d bp = // point used to select nearest point in pointList // Because the same source element can be passed // to the function given to Aggregate() many times, // we cache each point along with the result of calling // DistanceTo() in an anonymous type, allowing us to // avoid redundant calls to DistanceTo(): var items = pointList.Select( p => new{ point = p, dist = p.DistanceTo( bp ) } ); // Find the nearest point: Point3d nearest = items.Aggregate( ( a, b ) => a.dist < b.dist ? a : b ).point; */ }