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
- ClusterRegistryConfigurationProvider.cs
- KeyFrames.cs
- X509Certificate2Collection.cs
- FlowNode.cs
- XslAst.cs
- SafeBitVector32.cs
- MD5CryptoServiceProvider.cs
- XomlSerializationHelpers.cs
- MouseActionConverter.cs
- ParserOptions.cs
- EntityClassGenerator.cs
- ListViewInsertedEventArgs.cs
- CancelEventArgs.cs
- SoapFault.cs
- Italic.cs
- SecurityContextTokenValidationException.cs
- SafeCertificateContext.cs
- QueryContinueDragEvent.cs
- LinkedResource.cs
- DataGridViewHeaderCell.cs
- FontInfo.cs
- IndexerNameAttribute.cs
- IRCollection.cs
- TimeSpanSecondsConverter.cs
- UITypeEditor.cs
- RenameRuleObjectDialog.cs
- TreeView.cs
- RequestSecurityTokenForRemoteTokenFactory.cs
- SqlNodeAnnotation.cs
- DataTableReader.cs
- webproxy.cs
- DbConnectionStringCommon.cs
- XmlAttributeCollection.cs
- CodeIdentifier.cs
- XmlSchemaGroup.cs
- DataDocumentXPathNavigator.cs
- StoryFragments.cs
- MonitoringDescriptionAttribute.cs
- Expr.cs
- ConstraintStruct.cs
- ToolboxItemCollection.cs
- ValidationErrorCollection.cs
- FloaterBaseParagraph.cs
- ResXBuildProvider.cs
- ControlAdapter.cs
- QuaternionValueSerializer.cs
- TreeNode.cs
- PenThreadWorker.cs
- ListManagerBindingsCollection.cs
- LongValidator.cs
- FastEncoderStatics.cs
- Nodes.cs
- X509ChainElement.cs
- PagedDataSource.cs
- MergeFilterQuery.cs
- SecureStringHasher.cs
- MetaModel.cs
- Debug.cs
- DispatcherTimer.cs
- recordstatefactory.cs
- EpmContentDeSerializer.cs
- KeyValuePairs.cs
- CodeNamespaceImport.cs
- HwndMouseInputProvider.cs
- DataListCommandEventArgs.cs
- AsymmetricAlgorithm.cs
- SqlBuffer.cs
- SolidBrush.cs
- TextOptions.cs
- DataMemberFieldEditor.cs
- ProjectionCamera.cs
- SkinBuilder.cs
- PersonalizationStateInfoCollection.cs
- MasterPageBuildProvider.cs
- Polyline.cs
- SqlBuilder.cs
- UrlPath.cs
- RequiredAttributeAttribute.cs
- VariantWrapper.cs
- InstanceValue.cs
- FunctionNode.cs
- SchemaElementLookUpTable.cs
- DbBuffer.cs
- InvalidPropValue.cs
- RegexInterpreter.cs
- Matrix3DConverter.cs
- TextDecorations.cs
- XPathAxisIterator.cs
- TableColumn.cs
- EdmItemError.cs
- ConstraintConverter.cs
- SQLGuidStorage.cs
- MatrixKeyFrameCollection.cs
- TypedDatasetGenerator.cs
- ConfigXmlCDataSection.cs
- XmlDataImplementation.cs
- TypeUtil.cs
- KeyInterop.cs
- DataTable.cs
- SqlFileStream.cs