Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Core / CSharp / System / Windows / Media3D / ProjectionCamera.cs / 1305600 / 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
- XPathSelfQuery.cs
- DialogResultConverter.cs
- AvtEvent.cs
- EntityDataSourceState.cs
- SelectionPattern.cs
- documentsequencetextview.cs
- SelectedCellsChangedEventArgs.cs
- EntityContainerEmitter.cs
- HttpCacheParams.cs
- precedingsibling.cs
- Int32CollectionConverter.cs
- BinaryFormatter.cs
- EditorZoneBase.cs
- FlowPosition.cs
- FormCollection.cs
- OLEDB_Util.cs
- XmlWriter.cs
- initElementDictionary.cs
- TraceUtility.cs
- Converter.cs
- DrawingDrawingContext.cs
- ConstraintManager.cs
- glyphs.cs
- InputLangChangeEvent.cs
- OleDbStruct.cs
- ControlBuilderAttribute.cs
- DataSourceXmlAttributeAttribute.cs
- WindowsTooltip.cs
- ApplySecurityAndSendAsyncResult.cs
- ResXBuildProvider.cs
- IntegerValidatorAttribute.cs
- SerializationInfo.cs
- InfoCardRSAOAEPKeyExchangeFormatter.cs
- MultiDataTrigger.cs
- EntityTransaction.cs
- XmlSchemaCompilationSettings.cs
- InvalidCommandTreeException.cs
- Slider.cs
- ConnectionManagementElement.cs
- ChtmlTextWriter.cs
- X509KeyIdentifierClauseType.cs
- UnaryQueryOperator.cs
- BitmapEffectGeneralTransform.cs
- WSDualHttpBinding.cs
- ObjectView.cs
- AuthenticationConfig.cs
- SocketElement.cs
- EntitySqlQueryBuilder.cs
- ScrollChangedEventArgs.cs
- UpdateCompiler.cs
- ComponentCommands.cs
- SettingsPropertyNotFoundException.cs
- ResourceSet.cs
- ProgressPage.cs
- UserPreferenceChangingEventArgs.cs
- CardSpacePolicyElement.cs
- SimpleRecyclingCache.cs
- Utils.cs
- ConfigUtil.cs
- DesignerActionItem.cs
- DataSpaceManager.cs
- ManipulationPivot.cs
- DesignerProperties.cs
- DrawListViewSubItemEventArgs.cs
- SspiNegotiationTokenProvider.cs
- ClientScriptItemCollection.cs
- SecurityElementBase.cs
- TemplateXamlTreeBuilder.cs
- IIS7WorkerRequest.cs
- AccessDataSource.cs
- MergeFilterQuery.cs
- EncodingTable.cs
- CompilerInfo.cs
- SettingsPropertyValueCollection.cs
- RichTextBox.cs
- Matrix3DConverter.cs
- ClientSession.cs
- CriticalExceptions.cs
- UrlMappingsSection.cs
- PropertyEntry.cs
- SecurityKeyIdentifierClause.cs
- ParserOptions.cs
- DataServiceRequestArgs.cs
- InternalRelationshipCollection.cs
- BookmarkScopeHandle.cs
- CapabilitiesSection.cs
- Polyline.cs
- TableRowGroup.cs
- Brushes.cs
- SecureUICommand.cs
- Stacktrace.cs
- MultidimensionalArrayItemReference.cs
- BufferCache.cs
- NumberFormatInfo.cs
- Hyperlink.cs
- ObjectFactoryCodeDomTreeGenerator.cs
- SqlClientWrapperSmiStream.cs
- DbXmlEnabledProviderManifest.cs
- Claim.cs
- SessionStateUtil.cs