public Transform3DCollection OutDownFrontRight(Point3D SourcePosition, Point3D TargetPosition, double Wait, double Duration) { Transform3DCollection tc = new Transform3DCollection(); DoubleAnimation xa = new DoubleAnimation(SourcePosition.X, TargetPosition.X, new Duration(TimeSpan.FromSeconds(Duration / 2))) { BeginTime = TimeSpan.FromSeconds(0) }; DoubleAnimation ya = new DoubleAnimation(SourcePosition.Y, TargetPosition.Y, new Duration(TimeSpan.FromSeconds(Duration / 2))) { BeginTime = TimeSpan.FromSeconds(Duration / 2) }; DoubleAnimation za = new DoubleAnimation(SourcePosition.Z, TargetPosition.Z, new Duration(TimeSpan.FromSeconds(Duration / 2))) { BeginTime = TimeSpan.FromSeconds(Duration / 2) }; TranslateTransform3D xt = new TranslateTransform3D(); xt.BeginAnimation(TranslateTransform3D.OffsetXProperty, xa); TranslateTransform3D yt = new TranslateTransform3D(); yt.BeginAnimation(TranslateTransform3D.OffsetYProperty, ya); TranslateTransform3D zt = new TranslateTransform3D(); zt.BeginAnimation(TranslateTransform3D.OffsetZProperty, za); tc.Add(xt); tc.Add(yt); tc.Add(zt); return(tc); }
private void InitializeModels() { // create Main Model group - light and transforms for all sub model groups go here _MainGroup = new Model3DGroup(); // Create default Transform collection // Add transform collection to the _MainGroup _GroupScaleTransform = new ScaleTransform3D(new Vector3D(1, 1, 1)); _GroupRotateTransformY = new RotateTransform3D( new AxisAngleRotation3D(new Vector3D(0, 1, 0), 0), new Point3D(0, 0, 0)); _GroupTranslateTransform = new TranslateTransform3D(new Vector3D(0, 1, 0)); Transform3DCollection tcollection = new Transform3DCollection(); tcollection.Add(_GroupScaleTransform); tcollection.Add(_GroupRotateTransformY); tcollection.Add(_GroupTranslateTransform); // setup group transform Transform3DGroup tGroupDefault = new Transform3DGroup(); tGroupDefault.Children = tcollection; _MainGroup.Transform = tGroupDefault; // Create sub model group [0] for the light // _ModelLights = new Model3DGroup(); AmbientLight light1 = new AmbientLight(Colors.White); _ModelLights.Transform = tGroupDefault.Clone(); _ModelLights.Children.Add(light1); _MainGroup.Children.Add(_ModelLights); _ModelItems = new Model3DGroup(); _MainGroup.Children.Add(_ModelItems); }
private void OnLoaded(object sender, RoutedEventArgs e) { // Trackball setup _trackball = new Trackball(); _trackball.Attach(this); _trackball.Slaves.Add(_viewport3D); _trackball.Enabled = true; if (this.ItemsSource is ChartPlanes) { _planes = this.ItemsSource as ChartPlanes; } else { return; } // Add 3D model Content _viewport3D.Children.Clear(); _modelGroup = new Model3DGroup(); ScaleTransform3D GroupScaleTransform = new ScaleTransform3D(new Vector3D(0.74, 1, 1)); RotateTransform3D GroupRotateTransform = new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 1, 0), 0), new Point3D(0, 0, 0)); TranslateTransform3D GroupTranslateTransform = new TranslateTransform3D(new Vector3D(0, 0, 0)); Transform3DCollection tcollection = new Transform3DCollection(); tcollection.Add(GroupScaleTransform); tcollection.Add(GroupRotateTransform); tcollection.Add(GroupTranslateTransform); Transform3DGroup tGroupDefault = new Transform3DGroup(); tGroupDefault.Children = tcollection; _modelGroup.Transform = tGroupDefault; Model3DGroup submodelGroup = new Model3DGroup(); submodelGroup.Children.Add(new AmbientLight(Colors.White)); _modelGroup.Children.Add(submodelGroup); ModelVisual3D mv3d = new ModelVisual3D(); GroupScaleTransform = new ScaleTransform3D(new Vector3D(1, 1, 1)); GroupRotateTransform = new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 1, 0), 0), new Point3D(0, 0, 0)); GroupTranslateTransform = new TranslateTransform3D(new Vector3D(0, 0, 0)); tcollection = new Transform3DCollection(); tcollection.Add(GroupScaleTransform); tcollection.Add(GroupRotateTransform); tcollection.Add(GroupTranslateTransform); tGroupDefault = new Transform3DGroup(); tGroupDefault.Children = tcollection; mv3d.Transform = tGroupDefault; mv3d.Content = _modelGroup; _viewport3D.Children.Add(mv3d); }
// Updates the matrices of the slaves using the rotation quaternion. private void UpdateServants(Quaternion q, double s) { var rotation = new RotateTransform3D(); //IB: changed this var quatRotation = new QuaternionRotation3D(q); rotation.Rotation = quatRotation; //rotation.Rotation = new Rotation3D(q); rotation.CenterX = _center.X; rotation.CenterY = _center.Y; var scale = new ScaleTransform3D(new Vector3D(s, s, s)); var rotateAndScale = new Transform3DCollection { scale, rotation }; //IB: moved out of the constructor above if (_servants != null) { foreach (var i in _servants) { // Note that we don't copy constantly here, we copy the first time someone tries to // trackball a frozen Models, but we replace it with a ChangeableReference // and so subsequent interactions go through without a copy. /* mijacobs: commenting out * if (i.Models.Transform.IsFrozen) * { * Model3DGroup mutableCopy = i.Models.Copy(); * //mutableCopy.StatusOfNextUse = UseStatus.ChangeableReference; IB: no longer necessary I need to architect this out if time permits * i.Models = mutableCopy; * }*/ var myTransformGroup = new Transform3DGroup { Children = rotateAndScale }; //IB: added transformGroup // mijacobs old: i.Models.Transform = myTransformGroup; ((Model3DGroup)((ModelVisual3D)i.Children[0]).Content).Transform = myTransformGroup; } } }
public void SetToDefaultPosition(Vector3D scale, Vector3D translate, Vector3D rotateY, double angleY) { AngleY = angleY; _GroupScaleTransform = new ScaleTransform3D(scale); _GroupTranslateTransform = new TranslateTransform3D(translate); _GroupRotateTransformY = new RotateTransform3D(new AxisAngleRotation3D(rotateY, angleY)); Transform3DCollection tcollection = new Transform3DCollection(); tcollection.Add(_GroupScaleTransform); tcollection.Add(_GroupRotateTransformY); tcollection.Add(_GroupTranslateTransform); // setup group transform Transform3DGroup tGroupDefault = new Transform3DGroup(); tGroupDefault.Children = tcollection; _ItemGroup.Transform = tGroupDefault; return; }
// Updates the matrices of the slaves using the rotation quaternion. private void UpdateServants(Quaternion q, double s) { var rotation = new RotateTransform3D(); //IB: changed this var quatRotation = new QuaternionRotation3D(q); rotation.Rotation = quatRotation; //rotation.Rotation = new Rotation3D(q); rotation.CenterX = _center.X; rotation.CenterY = _center.Y; var scale = new ScaleTransform3D(new Vector3D(s, s, s)); var rotateAndScale = new Transform3DCollection {scale, rotation}; //IB: moved out of the constructor above if (_servants != null) { foreach (var i in _servants) { // Note that we don't copy constantly here, we copy the first time someone tries to // trackball a frozen Models, but we replace it with a ChangeableReference // and so subsequent interactions go through without a copy. /* mijacobs: commenting out if (i.Models.Transform.IsFrozen) { Model3DGroup mutableCopy = i.Models.Copy(); //mutableCopy.StatusOfNextUse = UseStatus.ChangeableReference; IB: no longer necessary I need to architect this out if time permits i.Models = mutableCopy; }*/ var myTransformGroup = new Transform3DGroup {Children = rotateAndScale}; //IB: added transformGroup // mijacobs old: i.Models.Transform = myTransformGroup; ((Model3DGroup) ((ModelVisual3D) i.Children[0]).Content).Transform = myTransformGroup; } } }
private void setRotation() { var rotations = new Transform3DCollection(); var transformGroup = new Transform3DGroup() { Children = rotations }; geometry.Transform = transformGroup; rotations.Add(new RotateTransform3D( new QuaternionRotation3D( new Quaternion(new Vector3D(0, 1, 0), AngleX) ) ) ); rotations.Add(new RotateTransform3D( new QuaternionRotation3D( new Quaternion(new Vector3D(1, 0, 0), AngleY) ) ) ); }
/// <summary> /// Reset set the view of 3D chart /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cmResetView_Click(object sender, RoutedEventArgs e) { Transform3DCollection collection = new Transform3DCollection(); collection.Add(new RotateTransform3D(new AxisAngleRotation3D() { Angle = -40, Axis = new Vector3D(0, 1, 0) })); collection.Add(new RotateTransform3D(new AxisAngleRotation3D() { Angle = 20, Axis = new Vector3D(1, 0, 0) })); Transform3DGroup group = new Transform3DGroup() { Children = collection, }; chartBlindSearch.ContentTransform = group; }
/// <summary> /// Reset set the view of 3D chart /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cmResetView_Click(object sender, RoutedEventArgs e) { Transform3DCollection collection = new Transform3DCollection { new RotateTransform3D(new AxisAngleRotation3D() { Angle = -40, Axis = new Vector3D(0, 1, 0) }), new RotateTransform3D(new AxisAngleRotation3D() { Angle = 20, Axis = new Vector3D(1, 0, 0) }) }; Transform3DGroup group = new Transform3DGroup() { Children = collection, }; this.ContentTransform = group; }
public Transform3DGroup() { Children = new Transform3DCollection(); }