Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / Core / CSharp / System / Windows / Media3D / ProjectionCamera.cs / 1 / ProjectionCamera.cs
//---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // //--------------------------------------------------------------------------- using System; namespace System.Windows.Media.Media3D { ////// The ProjectionCamera is an abstract base class from cameras /// constructed from well-understand parameers such as Position, /// LookAtPoint, and Up. /// public abstract partial class ProjectionCamera : Camera { //----------------------------------------------------- // // Constructors // //----------------------------------------------------- ////// Prevent 3rd parties from extending this abstract base class. /// internal ProjectionCamera() { } //------------------------------------------------------ // // Public Methods // //----------------------------------------------------- //------------------------------------------------------ // // Public Properties // //------------------------------------------------------ //----------------------------------------------------- // // Public Events // //------------------------------------------------------ //----------------------------------------------------- // // Internal Methods // //----------------------------------------------------- #region Internal Methods internal override Matrix3D GetViewMatrix() { Point3D position = Position; Vector3D lookDirection = LookDirection; Vector3D upDirection = UpDirection; return CreateViewMatrix(Transform, ref position, ref lookDirection, ref upDirection); } // Transfrom that moves the world to a camera coordinate system // where the camera is at the origin looking down the negative z // axis and y is up. // // NOTE: We consider camera.Transform to be part of the view matrix. // internal static Matrix3D CreateViewMatrix(Transform3D transform, ref Point3D position, ref Vector3D lookDirection, ref Vector3D upDirection) { Vector3D zaxis = -lookDirection; zaxis.Normalize(); Vector3D xaxis = Vector3D.CrossProduct(upDirection, zaxis); xaxis.Normalize(); Vector3D yaxis = Vector3D.CrossProduct(zaxis, xaxis); Vector3D positionVec = (Vector3D) position; double cx = -Vector3D.DotProduct(xaxis, positionVec); double cy = -Vector3D.DotProduct(yaxis, positionVec); double cz = -Vector3D.DotProduct(zaxis, positionVec); Matrix3D viewMatrix = new Matrix3D( xaxis.X, yaxis.X, zaxis.X, 0, xaxis.Y, yaxis.Y, zaxis.Y, 0, xaxis.Z, yaxis.Z, zaxis.Z, 0, cx, cy, cz, 1); PrependInverseTransform(transform, ref viewMatrix); return viewMatrix; } #endregion Internal Methods //----------------------------------------------------- // // Private Fields // //------------------------------------------------------ } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. //---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // //--------------------------------------------------------------------------- using System; namespace System.Windows.Media.Media3D { ////// The ProjectionCamera is an abstract base class from cameras /// constructed from well-understand parameers such as Position, /// LookAtPoint, and Up. /// public abstract partial class ProjectionCamera : Camera { //----------------------------------------------------- // // Constructors // //----------------------------------------------------- ////// Prevent 3rd parties from extending this abstract base class. /// internal ProjectionCamera() { } //------------------------------------------------------ // // Public Methods // //----------------------------------------------------- //------------------------------------------------------ // // Public Properties // //------------------------------------------------------ //----------------------------------------------------- // // Public Events // //------------------------------------------------------ //----------------------------------------------------- // // Internal Methods // //----------------------------------------------------- #region Internal Methods internal override Matrix3D GetViewMatrix() { Point3D position = Position; Vector3D lookDirection = LookDirection; Vector3D upDirection = UpDirection; return CreateViewMatrix(Transform, ref position, ref lookDirection, ref upDirection); } // Transfrom that moves the world to a camera coordinate system // where the camera is at the origin looking down the negative z // axis and y is up. // // NOTE: We consider camera.Transform to be part of the view matrix. // internal static Matrix3D CreateViewMatrix(Transform3D transform, ref Point3D position, ref Vector3D lookDirection, ref Vector3D upDirection) { Vector3D zaxis = -lookDirection; zaxis.Normalize(); Vector3D xaxis = Vector3D.CrossProduct(upDirection, zaxis); xaxis.Normalize(); Vector3D yaxis = Vector3D.CrossProduct(zaxis, xaxis); Vector3D positionVec = (Vector3D) position; double cx = -Vector3D.DotProduct(xaxis, positionVec); double cy = -Vector3D.DotProduct(yaxis, positionVec); double cz = -Vector3D.DotProduct(zaxis, positionVec); Matrix3D viewMatrix = new Matrix3D( xaxis.X, yaxis.X, zaxis.X, 0, xaxis.Y, yaxis.Y, zaxis.Y, 0, xaxis.Z, yaxis.Z, zaxis.Z, 0, cx, cy, cz, 1); PrependInverseTransform(transform, ref viewMatrix); return viewMatrix; } #endregion Internal Methods //----------------------------------------------------- // // 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
- AtlasWeb.Designer.cs
- ContentControl.cs
- CachingHintValidation.cs
- namescope.cs
- SwitchLevelAttribute.cs
- LineInfo.cs
- DataTrigger.cs
- Subset.cs
- XmlSchemaParticle.cs
- WorkflowTraceTransfer.cs
- ZeroOpNode.cs
- KeyValueInternalCollection.cs
- BufferedGraphicsManager.cs
- DbgCompiler.cs
- DrawListViewItemEventArgs.cs
- StyleModeStack.cs
- ContainerUIElement3D.cs
- SerializerProvider.cs
- HashAlgorithm.cs
- TogglePattern.cs
- TransactionFlowBindingElement.cs
- Membership.cs
- _ShellExpression.cs
- OdbcCommandBuilder.cs
- FormsAuthenticationModule.cs
- PageAdapter.cs
- TableLayoutSettingsTypeConverter.cs
- SkinBuilder.cs
- SafeNativeMethodsOther.cs
- MetadataPropertyAttribute.cs
- CatalogZoneBase.cs
- CodeDomDesignerLoader.cs
- ParseNumbers.cs
- CodeIterationStatement.cs
- EventSinkActivity.cs
- ReachVisualSerializer.cs
- SendActivityEventArgs.cs
- XslVisitor.cs
- SeekStoryboard.cs
- SafePointer.cs
- IndexerReference.cs
- AnnotationStore.cs
- RootNamespaceAttribute.cs
- PointCollectionConverter.cs
- GridErrorDlg.cs
- XmlComplianceUtil.cs
- ObjectDataSourceView.cs
- ProxyHelper.cs
- CheckableControlBaseAdapter.cs
- DirtyTextRange.cs
- PrimitiveXmlSerializers.cs
- AuthenticationService.cs
- WsatConfiguration.cs
- _BaseOverlappedAsyncResult.cs
- NativeMethods.cs
- WindowsComboBox.cs
- LicenseProviderAttribute.cs
- MultipartContentParser.cs
- ReflectionTypeLoadException.cs
- XmlName.cs
- RewritingProcessor.cs
- TablePattern.cs
- ObjectDataProvider.cs
- StringTraceRecord.cs
- HijriCalendar.cs
- safesecurityhelperavalon.cs
- ExpressionConverter.cs
- Int64KeyFrameCollection.cs
- EntityContainerRelationshipSet.cs
- EntityContainerEmitter.cs
- Positioning.cs
- CategoryGridEntry.cs
- TableRow.cs
- UriTemplateHelpers.cs
- PngBitmapEncoder.cs
- DefaultHttpHandler.cs
- ToolStripStatusLabel.cs
- configsystem.cs
- CacheChildrenQuery.cs
- XmlSchemaAnyAttribute.cs
- LocationUpdates.cs
- _FtpControlStream.cs
- GorillaCodec.cs
- XamlSerializer.cs
- RawStylusSystemGestureInputReport.cs
- IdentitySection.cs
- XamlStream.cs
- KeyInfo.cs
- DSASignatureDeformatter.cs
- StatusBar.cs
- CryptoConfig.cs
- TrackingStringDictionary.cs
- DecimalAnimationBase.cs
- WebPartZoneCollection.cs
- DataGridViewCellConverter.cs
- RefType.cs
- ProvidersHelper.cs
- XmlSecureResolver.cs
- InstanceDataCollection.cs
- Binding.cs