public SimulationVisualTier3D(ITierInfo tier, DetailLevel detailLevel) : base(tier) { _tier = tier; var visual = new BoxVisual3D { Fill = VisualizationConstants.BrushTierVisual, Center = new Point3D( (_tier.GetInfoTLX() + _tier.GetInfoLength()) / 2.0, (_tier.GetInfoTLY() + _tier.GetInfoWidth()) / 2.0, _tier.GetInfoZ() - TIER_HEIGHT / 2.0), Length = _tier.GetInfoLength(), Width = _tier.GetInfoWidth(), Height = TIER_HEIGHT }; Children.Add(visual); }
public void UpdateTransformation(bool overrideUpdate) { if (_moveableObject.GetInfoChanged() || overrideUpdate) { // Fetch necessary information ITierInfo tier = _moveableObject.GetInfoCurrentTier(); if (tier != null) { // Get position double xOffset = tier.GetInfoTLX() + _moveableObject.GetInfoCenterX(); double yOffset = tier.GetInfoTLY() + _moveableObject.GetInfoCenterY(); double zOffset = tier.GetInfoZ() + GetZ(); double orientationInDegrees = _moveableObject.GetInfoOrientation() / (2 * Math.PI) * 360; //// Fetch transformers // TODO is it really necessary to "new" the transformer objects? //Transform3DGroup tg = (Transform3DGroup)Transform; //TranslateTransform3D positionTransform = (TranslateTransform3D)tg.Children.First(); //RotateTransform3D rotationTransform = (RotateTransform3D)tg.Children.Last(); //// Set new information //positionTransform.OffsetX = xOffset; //positionTransform.OffsetY = yOffset; //positionTransform.OffsetZ = zOffset; // Update visual object itself Transform3DGroup tg = new Transform3DGroup(); tg.Children.Add(new TranslateTransform3D(xOffset, yOffset, zOffset)); tg.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 0, 1), _moveableObject.GetInfoOrientation() / (2 * Math.PI) * 360), new Point3D(xOffset, yOffset, zOffset))); Transform = tg; // Update onboard camera, if attached if (_onboardCameraAttached) { double angle = _moveableObject.GetInfoOrientation() + 0.5 * Math.PI; CameraHelper.AnimateTo( _camera, // The camera to adjust new Point3D(xOffset, yOffset, tier.GetInfoZ() + _height + 0.05), // The position of the camera new Vector3D(Math.Sin(angle), -Math.Cos(angle), 0), // The direction the camera is facing new Vector3D(0, 0, 1), // The roll of the camera - just keep it upright 0); // The animation time } } } // Update meta info UpdateMetaInfo(); }