Code:
/ DotNET / DotNET / 8.0 / untmp / WIN_WINDOWS / lh_tools_devdiv_wpf / Windows / wcp / Core / System / Windows / Media3D / RayHitTestParameters.cs / 3 / RayHitTestParameters.cs
//---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // History: // 03/16/2004 : [....] - Created // //--------------------------------------------------------------------------- using System; using System.IO; using System.Diagnostics; using System.Collections.Generic; using MS.Internal.Media3D; using CultureInfo = System.Globalization.CultureInfo; namespace System.Windows.Media.Media3D { ////// Encapsulates a set parameters for performing a 3D hit test agaist /// a ray. /// public sealed class RayHitTestParameters : HitTestParameters3D { //----------------------------------------------------- // // Constructors // //----------------------------------------------------- #region Constructors ////// Creates a RayHitTestParameters where the ray is described /// by an origin and a direction. /// public RayHitTestParameters(Point3D origin, Vector3D direction) { _origin = origin; _direction = direction; _isRay = true; } #endregion Constructors //------------------------------------------------------ // // Public Methods // //----------------------------------------------------- //------------------------------------------------------ // // Public Properties // //------------------------------------------------------ #region Public Properties ////// The origin of the ray to be used for hit testing. /// public Point3D Origin { get { return _origin; } } ////// The direction of the ray to be used for hit testing. /// public Vector3D Direction { get { return _direction; } } #endregion Public Properties //----------------------------------------------------- // // Public Events // //------------------------------------------------------ //----------------------------------------------------- // // Internal Methods // //----------------------------------------------------- #region Internal Methods internal void ReportResult( MeshGeometry3D meshHit, Point3D pointHit, double distanceToRayOrigin, int vertexIndex1, int vertexIndex2, int vertexIndex3, Point barycentric) { results.Add(new RayMeshGeometry3DHitTestResult( CurrentVisual, CurrentModel, meshHit, pointHit, distanceToRayOrigin, vertexIndex1, vertexIndex2, vertexIndex3, barycentric)); } internal HitTestResultBehavior RaiseCallback(HitTestResultCallback resultCallback, HitTestFilterCallback filterCallback, HitTestResultBehavior lastResult) { return RaiseCallback(resultCallback, filterCallback, lastResult, 0.0 /* distance adjustment */); } internal HitTestResultBehavior RaiseCallback(HitTestResultCallback resultCallback, HitTestFilterCallback filterCallback, HitTestResultBehavior lastResult, double distanceAdjustment) { results.Sort(RayHitTestResult.CompareByDistanceToRayOrigin); for(int i = 0, count = results.Count; i < count; i++) { RayHitTestResult result = results[i]; result.SetDistanceToRayOrigin(result.DistanceToRayOrigin + distanceAdjustment); Viewport2DVisual3D viewport2DVisual3D = result.VisualHit as Viewport2DVisual3D; if (viewport2DVisual3D != null) { Point intersectionPoint; Visual viewport2DVisual3DChild = viewport2DVisual3D.Visual; if (viewport2DVisual3DChild != null) { if (Viewport2DVisual3D.GetIntersectionInfo(result, out intersectionPoint)) { // convert the resulting point to visual coordinates Point visualPoint = Viewport2DVisual3D.TextureCoordsToVisualCoords(intersectionPoint, viewport2DVisual3DChild); GeneralTransform gt = viewport2DVisual3DChild.TransformToOuterSpace().Inverse; Point pointOnChild; if (gt != null && gt.TryTransform(visualPoint, out pointOnChild)) { HitTestResultBehavior behavior2D = viewport2DVisual3DChild.HitTestPoint(filterCallback, resultCallback, new PointHitTestParameters(pointOnChild)); if (behavior2D == HitTestResultBehavior.Stop) { return HitTestResultBehavior.Stop; } } } } } HitTestResultBehavior behavior = resultCallback(results[i]); if (behavior == HitTestResultBehavior.Stop) { return HitTestResultBehavior.Stop; } } return lastResult; } // Gets the hit testing line/ray specified as an origin and direction in // the current local space. internal void GetLocalLine(out Point3D origin, out Vector3D direction) { origin = _origin; direction = _direction; bool isRay = true; if (HasWorldTransformMatrix) { LineUtil.Transform(WorldTransformMatrix, ref origin, ref direction, out isRay); } // At any point along the tree walk we may encounter a transform that turns the ray into // a line and if so we must stay a line _isRay &= isRay; } internal void ClearResults() { if (results != null) { results.Clear(); } } #endregion Internal Methods internal bool IsRay { get { return _isRay; } } //----------------------------------------------------- // // Private Fields // //------------------------------------------------------ #region Private Fields private readonly Point3D _origin; private readonly Vector3D _direction; private readonly Listresults = new List (); // 'true' if this is a ray hit test, 'false' if the ray has become a line private bool _isRay; #endregion Private Fields } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- AppDomainFactory.cs
- TerminatorSinks.cs
- httpapplicationstate.cs
- DynamicValidatorEventArgs.cs
- documentsequencetextpointer.cs
- FilterQuery.cs
- HtmlInputRadioButton.cs
- StartUpEventArgs.cs
- XamlSerializerUtil.cs
- UnmanagedMemoryStreamWrapper.cs
- ColumnResizeAdorner.cs
- PackWebRequest.cs
- ArrayMergeHelper.cs
- TextCharacters.cs
- FontDifferentiator.cs
- DataKeyCollection.cs
- NopReturnReader.cs
- KeyGestureValueSerializer.cs
- ServiceHttpModule.cs
- ActivationServices.cs
- XmlSchemaObjectTable.cs
- DocumentSequenceHighlightLayer.cs
- SizeKeyFrameCollection.cs
- ClientApiGenerator.cs
- HtmlObjectListAdapter.cs
- MethodBuilderInstantiation.cs
- TextEditorCopyPaste.cs
- XmlSchemaObject.cs
- NativeDirectoryServicesQueryAPIs.cs
- RC2CryptoServiceProvider.cs
- Trace.cs
- HtmlInputControl.cs
- VariableBinder.cs
- PkcsMisc.cs
- EntitySqlQueryCacheKey.cs
- DependencyObjectType.cs
- SingleSelectRootGridEntry.cs
- SoapFormatExtensions.cs
- DynamicFilterExpression.cs
- Matrix3DValueSerializer.cs
- EmptyEnumerator.cs
- CallContext.cs
- HttpDictionary.cs
- DesignerEditorPartChrome.cs
- _NegoState.cs
- WebPartCollection.cs
- CodeParameterDeclarationExpressionCollection.cs
- GradientSpreadMethodValidation.cs
- LinqExpressionNormalizer.cs
- Label.cs
- XmlChildEnumerator.cs
- MultipartContentParser.cs
- ThreadExceptionEvent.cs
- CharacterString.cs
- InvokeProviderWrapper.cs
- ValueConversionAttribute.cs
- RequestCacheManager.cs
- SystemNetHelpers.cs
- PropertyFilter.cs
- NestedContainer.cs
- TcpChannelHelper.cs
- WindowsStatusBar.cs
- EncoderBestFitFallback.cs
- EnumType.cs
- PolicyFactory.cs
- ValuePatternIdentifiers.cs
- CallContext.cs
- SessionIDManager.cs
- TableDetailsCollection.cs
- TextEditorTables.cs
- AssemblyResourceLoader.cs
- ChildTable.cs
- DirectoryNotFoundException.cs
- TextWriter.cs
- WindowsImpersonationContext.cs
- SQLDecimal.cs
- ObjectStateEntryBaseUpdatableDataRecord.cs
- EventDescriptor.cs
- FixedPageStructure.cs
- TextRunProperties.cs
- TransformedBitmap.cs
- GridViewRowCollection.cs
- XdrBuilder.cs
- MailHeaderInfo.cs
- RotateTransform3D.cs
- PrivilegeNotHeldException.cs
- DisplayInformation.cs
- WinFormsComponentEditor.cs
- ValueUtilsSmi.cs
- ClientData.cs
- CultureTableRecord.cs
- UserControlAutomationPeer.cs
- SHA512Cng.cs
- EntityClassGenerator.cs
- Form.cs
- CodeIdentifiers.cs
- EnvelopedPkcs7.cs
- TransformValueSerializer.cs
- DesignerActionList.cs
- NativeMethods.cs