Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / 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
- HtmlContainerControl.cs
- LicenseManager.cs
- MyContact.cs
- EntityDataSourceWrapperCollection.cs
- XmlElementList.cs
- SqlColumnizer.cs
- ModelUIElement3D.cs
- _CookieModule.cs
- EasingQuaternionKeyFrame.cs
- XhtmlBasicObjectListAdapter.cs
- XsltException.cs
- SecurityChannelListener.cs
- ComplexLine.cs
- Rect3DValueSerializer.cs
- XmlWriterSettings.cs
- WebPartDisplayModeCancelEventArgs.cs
- BuilderPropertyEntry.cs
- HierarchicalDataBoundControl.cs
- Descriptor.cs
- ConnectionConsumerAttribute.cs
- FileCodeGroup.cs
- MergePropertyDescriptor.cs
- DBConnectionString.cs
- DynamicEntity.cs
- ListViewCommandEventArgs.cs
- TraceContextEventArgs.cs
- _NegoState.cs
- DataFormat.cs
- PieceNameHelper.cs
- GlyphShapingProperties.cs
- ResourceType.cs
- Input.cs
- Decimal.cs
- VisualStyleInformation.cs
- ObjectConverter.cs
- Assembly.cs
- SettingsSavedEventArgs.cs
- Converter.cs
- Journaling.cs
- KeyConverter.cs
- PersonalizationStateInfo.cs
- OracleConnectionFactory.cs
- ParseHttpDate.cs
- StateWorkerRequest.cs
- GridItemPattern.cs
- DataGridViewTextBoxColumn.cs
- AtomPub10CategoriesDocumentFormatter.cs
- WindowsFormsLinkLabel.cs
- TextEffect.cs
- Int32.cs
- HttpFileCollection.cs
- TrustManagerPromptUI.cs
- BaseDataListDesigner.cs
- ISAPIWorkerRequest.cs
- HeaderCollection.cs
- SelectedGridItemChangedEvent.cs
- EntitySqlQueryCacheKey.cs
- IItemProperties.cs
- SoapInteropTypes.cs
- VariableAction.cs
- DefaultTextStore.cs
- diagnosticsswitches.cs
- SystemColorTracker.cs
- ListViewInsertedEventArgs.cs
- InfoCardRSAPKCS1KeyExchangeDeformatter.cs
- AttributeSetAction.cs
- BinaryEditor.cs
- FirstMatchCodeGroup.cs
- ColumnBinding.cs
- ListSortDescriptionCollection.cs
- SystemResourceKey.cs
- Int32RectConverter.cs
- FilteredDataSetHelper.cs
- FormsAuthenticationModule.cs
- FixedSOMTableCell.cs
- SingleKeyFrameCollection.cs
- PlacementWorkspace.cs
- AccessDataSourceWizardForm.cs
- FieldNameLookup.cs
- SQLDouble.cs
- HtmlInputRadioButton.cs
- PropertyPathConverter.cs
- IsolatedStorageException.cs
- Range.cs
- ParentControlDesigner.cs
- CompModSwitches.cs
- EditorZoneDesigner.cs
- documentsequencetextcontainer.cs
- IndexingContentUnit.cs
- ViewStateException.cs
- QilStrConcatenator.cs
- RayHitTestParameters.cs
- BasicKeyConstraint.cs
- TaskbarItemInfo.cs
- InternalResources.cs
- WpfPayload.cs
- ReliableSessionBindingElement.cs
- ScriptingAuthenticationServiceSection.cs
- CustomWebEventKey.cs
- CompilerResults.cs