private void SelectionRequested(SelectionFrustum obj) { if (_pos == null) { return; } // The user has interactively edited the constrained sections -> propagate the information to the simulation core List <int> indices = new List <int>(); List <Double3> pos = _pos.GetList(); Double4x4 trafo = _gl.SceneGraph.AbsoluteTransformation; //trafo.Invert(); Double3 center = Double3.Zero; for (int i = 0; i < pos.Count; ++i) { double d; if (obj.IsPointInside(trafo.TransformPoint(pos[i]), out d)) { indices.Add(i); center += pos[i]; } } if (indices.Count > 0) { center /= indices.Count; SceneNode n = new SceneNode(); n.RelativeTranslation = center; CoordinateSystemSceneNode cs = new CoordinateSystemSceneNode(); //cs.RelativeTranslation = center; cs.Call <SceneNode>(m => m.Overlay = true); n.Add(cs); _gl.SceneGraph.Add(n); _sim.AddConstraint(new ConstrainedSection(cs, indices)); _sim.UpdateConstraintConfiguration(); } }
public bool RemoveConstraint(CoordinateSystemSceneNode n) { //TODO: Not really an elegant solution for (int i = 0; i < _constrainedSections.Count; ++i) { ConstrainedSection s = _constrainedSections[i] as ConstrainedSection; if (s != null && s.Node == n) { _constrainedSections.RemoveAt(i); _constraintConfigChanged = true; return(true); } } return(false); }
public ConstrainedSection(CoordinateSystemSceneNode cs, List <int> indices) : base(indices) { _cs = cs; }