当前位置: 首页>>代码示例>>C#>>正文


C# Vector3.Floor方法代码示例

本文整理汇总了C#中Vector3.Floor方法的典型用法代码示例。如果您正苦于以下问题:C# Vector3.Floor方法的具体用法?C# Vector3.Floor怎么用?C# Vector3.Floor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Vector3的用法示例。


在下文中一共展示了Vector3.Floor方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetBlock

 public void SetBlock(Vector3 position, Block value)
 {
     position = position.Floor();
     Vector3 relativePosition = position;
     position.X = (int)(position.X) / Chunk.Width;
     position.Y = 0;
     position.Z = (int)(position.Z) / Chunk.Depth;
     
     relativePosition.X = (int)(relativePosition.X) % Chunk.Width;
     relativePosition.Z = (int)(relativePosition.Z) % Chunk.Depth;
     
     if (!Chunks.ContainsKey(position))
         Chunks.Add(position, WorldGenerator.GenerateChunk(position, this));
     
     Chunks[position].SetBlock(relativePosition, value);
 }
开发者ID:keneo,项目名称:Craft.Net,代码行数:16,代码来源:Region.cs

示例2: UpdateBounds

		/// <summary>
		///		Update the bounds of the BillboardSet.
		/// </summary>
		public virtual void UpdateBounds()
		{
			if ( this.activeBillboards.Count == 0 )
			{
				// no billboards, so the bounding box is null
				this.aab.IsNull = true;
				this.boundingRadius = 0.0f;
			}
			else
			{
				float maxSqLen = -1.0f;
				Vector3 min = new Vector3( float.PositiveInfinity, float.PositiveInfinity, float.PositiveInfinity );
				Vector3 max = new Vector3( float.NegativeInfinity, float.NegativeInfinity, float.NegativeInfinity );

				foreach ( Billboard billboard in this.activeBillboards )
				{
					Vector3 pos = billboard.Position;
					min.Floor( pos );
					max.Ceil( pos );

					maxSqLen = Utility.Max( maxSqLen, pos.LengthSquared );
				}

				// adjust for billboard size
				float adjust = Utility.Max( this.defaultParticleWidth, this.defaultParticleHeight );
				Vector3 vecAdjust = new Vector3( adjust, adjust, adjust );
				min -= vecAdjust;
				max += vecAdjust;

				// update our local aabb
				this.aab.SetExtents( min, max );

				this.boundingRadius = Utility.Sqrt( maxSqLen );
			}
			// if we have a parent node, ask it to update us
			if ( this.parentNode != null )
			{
				this.parentNode.NeedUpdate();
			}
		}
开发者ID:WolfgangSt,项目名称:axiom,代码行数:43,代码来源:BillboardSet.cs

示例3: _generateCurvedIllusionPlaneVertexData

		private void _generateCurvedIllusionPlaneVertexData( HardwareVertexBuffer vertexBuffer, int ySegments, int xSegments, float xSpace, float halfWidth, float ySpace, float halfHeight, Matrix4 xform, bool firstTime, bool normals, Quaternion orientation, float curvature, float uTiles, float vTiles, int numberOfTexCoordSets, ref Vector3 min, ref Vector3 max, ref float maxSquaredLength )
		{
			// Imagine a large sphere with the camera located near the top
			// The lower the curvature, the larger the sphere
			// Use the angle from viewer to the points on the plane
			// Credit to Aftershock for the general approach
			Real cameraPosition;      // Camera position relative to sphere center

			// Derive sphere radius
			//Vector3 vertPos;  // position relative to camera
			//Real sphDist;      // Distance from camera to sphere along box vertex vector
			// Vector3 camToSph; // camera position to sphere
			Real sphereRadius;// Sphere radius
			// Actual values irrelevant, it's the relation between sphere radius and camera position that's important
			Real sphRadius = 100.0f;
			Real camDistance = 5.0f;

			sphereRadius = sphRadius - curvature;
			cameraPosition = sphereRadius - camDistance;

			Vector3 vec;
			Vector3 norm;
			float sphereDistance;
			unsafe
			{
				// lock the vertex buffer
				IntPtr data = vertexBuffer.Lock( BufferLocking.Discard );

				float* pData = (float*)data.ToPointer();

				for ( int y = 0; y < ySegments + 1; ++y )
				{
					for ( int x = 0; x < xSegments + 1; ++x )
					{
						// centered on origin
						vec.x = ( x * xSpace ) - halfWidth;
						vec.y = ( y * ySpace ) - halfHeight;
						vec.z = 0.0f;

						// transform by orientation and distance
						vec = xform * vec;

						// assign to geometry
						*pData++ = vec.x;
						*pData++ = vec.y;
						*pData++ = vec.z;

						// build bounds as we go
						if ( firstTime )
						{
							min = vec;
							max = vec;
							maxSquaredLength = vec.LengthSquared;
							firstTime = false;
						}
						else
						{
							min.Floor( vec );
							max.Ceil( vec );
							maxSquaredLength = Utility.Max( maxSquaredLength, vec.LengthSquared );
						}

						if ( normals )
						{
							norm = Vector3.UnitZ;
							norm = orientation * norm;

							*pData++ = vec.x;
							*pData++ = vec.y;
							*pData++ = vec.z;
						}

						// generate texture coordinates, normalize position, modify by orientation to return +y up
						vec = orientation.Inverse() * vec;
						vec.Normalize();

						// find distance to sphere
						sphereDistance = Utility.Sqrt( cameraPosition * cameraPosition * ( vec.y * vec.y - 1.0f ) + sphereRadius * sphereRadius ) - cameraPosition * vec.y;

						vec.x *= sphereDistance;
						vec.z *= sphereDistance;

						// use x and y on sphere as texture coordinates, tiled
						float s = vec.x * ( 0.01f * uTiles );
						float t = vec.z * ( 0.01f * vTiles );
						for ( int i = 0; i < numberOfTexCoordSets; i++ )
						{
							*pData++ = s;
							*pData++ = ( 1 - t );
						}
					} // x
				} // y

				// unlock the buffer
				vertexBuffer.Unlock();
			} // unsafe
		}
开发者ID:WolfgangSt,项目名称:axiom,代码行数:97,代码来源:MeshManager.cs

示例4: _generateCurvedPlaneVertexData

		private void _generateCurvedPlaneVertexData( HardwareVertexBuffer vbuf, int ySegments, int xSegments, float xSpace, float halfWidth, float ySpace, float halfHeight, Matrix4 transform, bool firstTime, bool normals, Matrix4 rotation, float curvature, int numTexCoordSets, float xTexCoord, float yTexCoord, SubMesh subMesh, ref Vector3 min, ref Vector3 max, ref float maxSquaredLength )
		{
			Vector3 vec;
			unsafe
			{
				// lock the vertex buffer
				IntPtr data = vbuf.Lock( BufferLocking.Discard );

				float* pData = (float*)data.ToPointer();

				for ( int y = 0; y <= ySegments; y++ )
				{
					for ( int x = 0; x <= xSegments; x++ )
					{
						// centered on origin
						vec.x = ( x * xSpace ) - halfWidth;
						vec.y = ( y * ySpace ) - halfHeight;

						// Here's where curved plane is different from standard plane.  Amazing, I know.
						Real diff_x = ( x - ( (Real)xSegments / 2 ) ) / (Real)xSegments;
						Real diff_y = ( y - ( (Real)ySegments / 2 ) ) / (Real)ySegments;
						Real dist = Utility.Sqrt( diff_x * diff_x + diff_y * diff_y );
						vec.z = ( -Utility.Sin( ( 1 - dist ) * ( Utility.PI / 2 ) ) * curvature ) + curvature;

						// Transform by orientation and distance
						Vector3 pos = transform.TransformAffine( vec );

						*pData++ = pos.x;
						*pData++ = pos.y;
						*pData++ = pos.z;

						// Build bounds as we go
						if ( firstTime )
						{
							min = vec;
							max = vec;
							maxSquaredLength = vec.LengthSquared;
							firstTime = false;
						}
						else
						{
							min.Floor( vec );
							max.Ceil( vec );
							maxSquaredLength = Utility.Max( maxSquaredLength, vec.LengthSquared );
						}

						if ( normals )
						{
							// This part is kinda 'wrong' for curved planes... but curved planes are
							//   very valuable outside sky planes, which don't typically need normals
							//   so I'm not going to mess with it for now.

							// Default normal is along unit Z
							//vec = Vector3::UNIT_Z;
							// Rotate
							vec = rotation.TransformAffine( vec );

							*pData++ = vec.x;
							*pData++ = vec.y;
							*pData++ = vec.z;
						}

						for ( int i = 0; i < numTexCoordSets; i++ )
						{
							*pData++ = x * xTexCoord;
							*pData++ = 1 - ( y * yTexCoord );
						} // for texCoords
					} // for x
				} // for y

				// unlock the buffer
				vbuf.Unlock();

				subMesh.useSharedVertices = true;

			} // unsafe
		}
开发者ID:WolfgangSt,项目名称:axiom,代码行数:77,代码来源:MeshManager.cs

示例5: _generatePlaneVertexData

		private void _generatePlaneVertexData( HardwareVertexBuffer vbuf, int ySegments, int xSegments, float xSpace, float halfWidth, float ySpace, float halfHeight, Matrix4 transform, bool firstTime, bool normals, Matrix4 rotation, int numTexCoordSets, float xTexCoord, float yTexCoord, SubMesh subMesh, ref Vector3 min, ref Vector3 max, ref float maxSquaredLength )
		{
			Vector3 vec;
			unsafe
			{
				// lock the vertex buffer
				IntPtr data = vbuf.Lock( BufferLocking.Discard );

				float* pData = (float*)data.ToPointer();

				for ( int y = 0; y <= ySegments; y++ )
				{
					for ( int x = 0; x <= xSegments; x++ )
					{
						// centered on origin
						vec.x = ( x * xSpace ) - halfWidth;
						vec.y = ( y * ySpace ) - halfHeight;
						vec.z = 0.0f;

						vec = transform.TransformAffine( vec );

						*pData++ = vec.x;
						*pData++ = vec.y;
						*pData++ = vec.z;

						// Build bounds as we go
						if ( firstTime )
						{
							min = vec;
							max = vec;
							maxSquaredLength = vec.LengthSquared;
							firstTime = false;
						}
						else
						{
							min.Floor( vec );
							max.Ceil( vec );
							maxSquaredLength = Utility.Max( maxSquaredLength, vec.LengthSquared );
						}

						if ( normals )
						{
							vec = Vector3.UnitZ;
							vec = rotation.TransformAffine( vec );

							*pData++ = vec.x;
							*pData++ = vec.y;
							*pData++ = vec.z;
						}

						for ( int i = 0; i < numTexCoordSets; i++ )
						{
							*pData++ = x * xTexCoord;
							*pData++ = 1 - ( y * yTexCoord );
						} // for texCoords
					} // for x
				} // for y

				// unlock the buffer
				vbuf.Unlock();

				subMesh.useSharedVertices = true;

			} // unsafe
		}
开发者ID:WolfgangSt,项目名称:axiom,代码行数:65,代码来源:MeshManager.cs

示例6: ExtrudeBounds

		/// <summary>
		///		Utility method for extruding a bounding box.
		/// </summary>
		/// <param name="box">Original bounding box, will be updated in-place.</param>
		/// <param name="lightPosition">4D light position in object space, when w=0.0f this
		/// represents a directional light</param>
		/// <param name="extrudeDistance">The distance to extrude.</param>
		protected virtual void ExtrudeBounds( AxisAlignedBox box, Vector4 lightPosition, float extrudeDistance )
		{
			Vector3 extrusionDir = Vector3.Zero;

			if ( lightPosition.w == 0 )
			{
				extrusionDir.x = -lightPosition.x;
				extrusionDir.y = -lightPosition.y;
				extrusionDir.z = -lightPosition.z;
				extrusionDir.Normalize();
				extrusionDir *= extrudeDistance;
				box.SetExtents( box.Minimum + extrusionDir, box.Maximum + extrusionDir );
			}
			else
			{
				Vector3[] corners = box.Corners;
				Vector3 vmin = new Vector3();
				Vector3 vmax = new Vector3();

				for ( int i = 0; i < 8; i++ )
				{
					extrusionDir.x = corners[ i ].x - lightPosition.x;
					extrusionDir.y = corners[ i ].y - lightPosition.y;
					extrusionDir.z = corners[ i ].z - lightPosition.z;
					extrusionDir.Normalize();
					extrusionDir *= extrudeDistance;
					Vector3 res = corners[ i ] + extrusionDir;

					if ( i == 0 )
					{
						vmin = res;
						vmax = res;
					}
					else
					{
						vmin.Floor( res );
						vmax.Ceil( res );
					}
				}

				box.SetExtents( vmin, vmax );
			}
		}
开发者ID:mono-soc-2011,项目名称:axiom,代码行数:50,代码来源:ShadowCaster.cs

示例7: GenerateCurvedIllusionPlaneVertexData

        private static void GenerateCurvedIllusionPlaneVertexData(HardwareVertexBuffer vertexBuffer, int ySegments, int xSegments, float xSpace, float halfWidth, float ySpace, float halfHeight, Matrix4 xform, bool firstTime, bool normals, Quaternion orientation, float cameraPosition, float sphereRadius, float uTiles, float vTiles, int numberOfTexCoordSets, ref Vector3 min, ref Vector3 max, ref float maxSquaredLength)
        {
            Vector3 vec;
            Vector3 norm;
            float sphereDistance;
            unsafe {
                // lock the vertex buffer
                IntPtr data = vertexBuffer.Lock(BufferLocking.Discard);

                float* pData = (float*)data.ToPointer();

                for (int y = 0; y < ySegments + 1; ++y) {
                    for (int x = 0; x < xSegments + 1; ++x) {
                        // centered on origin
                        vec.x = (x * xSpace) - halfWidth;
                        vec.y = (y * ySpace) - halfHeight;
                        vec.z = 0.0f;

                        // transform by orientation and distance
                        vec = xform * vec;

                        // assign to geometry
                        *pData++ = vec.x;
                        *pData++ = vec.y;
                        *pData++ = vec.z;

                        // build bounds as we go
                        if (firstTime) {
                            min = vec;
                            max = vec;
                            maxSquaredLength = vec.LengthSquared;
                            firstTime = false;
                        } else {
                            min.Floor(vec);
                            max.Ceil(vec);
                            maxSquaredLength = MathUtil.Max(maxSquaredLength, vec.LengthSquared);
                        }

                        if (normals) {
                            norm = Vector3.UnitZ;
                            norm = orientation * norm;

                            *pData++ = vec.x;
                            *pData++ = vec.y;
                            *pData++ = vec.z;
                        }

                        // generate texture coordinates, normalize position, modify by orientation to return +y up
                        vec = orientation.Inverse() * vec;
                        vec.Normalize();

                        // find distance to sphere
                        sphereDistance = MathUtil.Sqrt(cameraPosition * cameraPosition * (vec.y * vec.y - 1.0f) + sphereRadius * sphereRadius) - cameraPosition * vec.y;

                        vec.x *= sphereDistance;
                        vec.z *= sphereDistance;

                        // use x and y on sphere as texture coordinates, tiled
                        float s = vec.x * (0.01f * uTiles);
                        float t = vec.z * (0.01f * vTiles);
                        for (int i = 0; i < numberOfTexCoordSets; i++) {
                            *pData++ = s;
                            *pData++ = (1 - t);
                        }
                    } // x
                } // y

                // unlock the buffer
                vertexBuffer.Unlock();
            } // unsafe
        }
开发者ID:ufosky-server,项目名称:MultiversePlatform,代码行数:71,代码来源:MeshManager.cs

示例8: NotifyCurrentCamera

		public override void NotifyCurrentCamera( Camera cam )
		{
			if ( this.mForcedRenderLevel >= 0 )
			{
				this.mRenderLevel = this.mForcedRenderLevel;
				return;
			}


			var cpos = cam.DerivedPosition;
			var aabb = GetWorldBoundingBox( true );
			var diff = new Vector3( 0, 0, 0 );
			diff.Floor( cpos - aabb.Minimum );
			diff.Ceil( cpos - aabb.Maximum );

			var L = diff.LengthSquared;

			this.mRenderLevel = -1;

			for ( var i = 0; i < this.mOptions.maxGeoMipMapLevel; i++ )
			{
				if ( this.mMinLevelDistSqr[ i ] > L )
				{
					this.mRenderLevel = i - 1;
					break;
				}
			}

			if ( this.mRenderLevel < 0 )
			{
				this.mRenderLevel = this.mOptions.maxGeoMipMapLevel - 1;
			}

			if ( this.mOptions.lodMorph )
			{
				// Get the next LOD level down
				var nextLevel = this.mNextLevelDown[ this.mRenderLevel ];
				if ( nextLevel == 0 )
				{
					// No next level, so never morph
					this.mLODMorphFactor = 0;
				}
				else
				{
					// Set the morph such that the morph happens in the last 0.25 of
					// the distance range
					var range = this.mMinLevelDistSqr[ nextLevel ] - this.mMinLevelDistSqr[ this.mRenderLevel ];
					if ( range > 0 )
					{
						var percent = ( L - this.mMinLevelDistSqr[ this.mRenderLevel ] )/range;
						// scale result so that msLODMorphStart == 0, 1 == 1, clamp to 0 below that
						var rescale = 1.0f/( 1.0f - this.mOptions.lodMorphStart );
						this.mLODMorphFactor = Math.Max( ( percent - this.mOptions.lodMorphStart )*rescale, 0.0 );
					}
					else
					{
						// Identical ranges
						this.mLODMorphFactor = 0.0f;
					}

					//assert(mLODMorphFactor >= 0 && mLODMorphFactor <= 1);
				}

				// Bind the correct delta buffer if it has changed
				// nextLevel - 1 since the first entry is for LOD 1 (since LOD 0 never needs it)
				if ( this.mLastNextLevel != nextLevel )
				{
					if ( nextLevel > 0 )
					{
						this.mTerrain.vertexBufferBinding.SetBinding( (short)DELTA_BINDING, this.mDeltaBuffers[ nextLevel - 1 ] );
					}
					else
					{
						// bind dummy (incase bindings checked)
						this.mTerrain.vertexBufferBinding.SetBinding( (short)DELTA_BINDING, this.mDeltaBuffers[ 0 ] );
					}
				}
				this.mLastNextLevel = nextLevel;
			}
		}
开发者ID:ryan-bunker,项目名称:axiom3d,代码行数:80,代码来源:TerrainZoneRenderable.cs

示例9: _updateFrustum


//.........这里部分代码省略.........
						q1.z = -1.0f;
						q1.w = ( 1.0f + this._projectionMatrix.m22 )/this._projectionMatrix.m23;

						// Calculate the scaled plane vector
						var clipPlane4d = new Vector4( plane.Normal.x, plane.Normal.y, plane.Normal.z, plane.D );
						var c = clipPlane4d*( 2.0f/( clipPlane4d.Dot( q1 ) ) );

						// Replace the third row of the projection matrix
						this._projectionMatrix.m20 = c.x;
						this._projectionMatrix.m21 = c.y;
						this._projectionMatrix.m22 = c.z + 1.0f;
						this._projectionMatrix.m23 = c.w;
					}
				} // perspective
				else if ( this._projectionType == Projection.Orthographic )
				{
					var A = 2.0f*inv_w;
					var B = 2.0f*inv_h;
					Real C = -( vpRight + vpLeft )*inv_w;
					Real D = -( vpTop + vpBottom )*inv_h;
					Real q, qn;
					if ( this._farDistance == 0.0f )
					{
						// Can not do infinite far plane here, avoid divided zero only
						q = -Frustum.InfiniteFarPlaneAdjust/this._nearDistance;
						qn = -Frustum.InfiniteFarPlaneAdjust - 1.0f;
					}
					else
					{
						q = -2.0f*inv_d;
						qn = -( this._farDistance + this._nearDistance )*inv_d;
					}

					// NB: This creates 'uniform' orthographic projection matrix,
					// which depth range [-1,1], right-handed rules
					//
					// [ A   0   0   C  ]
					// [ 0   B   0   D  ]
					// [ 0   0   q   qn ]
					// [ 0   0   0   1  ]
					//
					// A = 2 * / (right - left)
					// B = 2 * / (top - bottom)
					// C = - (right + left) / (right - left)
					// D = - (top + bottom) / (top - bottom)
					// q = - 2 / (far - near)
					// qn = - (far + near) / (far - near)

					this._projectionMatrix = Matrix4.Zero;
					this._projectionMatrix.m00 = A;
					this._projectionMatrix.m03 = C;
					this._projectionMatrix.m11 = B;
					this._projectionMatrix.m13 = D;
					this._projectionMatrix.m22 = q;
					this._projectionMatrix.m23 = qn;
					this._projectionMatrix.m33 = 1.0f;
				} // ortho
			} // if !_customProjectionMatrix

			// grab a reference to the current render system
			var renderSystem = Root.Instance.RenderSystem;
			// API specific
			renderSystem.ConvertProjectionMatrix( this._projectionMatrix, out this._projectionMatrixRS );
			// API specific for Gpu Programs
			renderSystem.ConvertProjectionMatrix( this._projectionMatrix, out this._projectionMatrixRSDepth, true );

			// Calculate bounding box (local)
			// Box is from 0, down -Z, max dimensions as determined from far plane
			// If infinite view frustum just pick a far value
			var farDist = ( this._farDistance == 0.0f ) ? InfiniteFarPlaneDistance : this._farDistance;

			// Near plane bounds
			var min = new Vector3( vpLeft, vpBottom, -farDist );
			var max = new Vector3( vpRight, vpTop, 0 );

			if ( this._customProjectionMatrix )
			{
				// Some custom projection matrices can have unusual inverted settings
				// So make sure the AABB is the right way around to start with
				var tmp = min;
				min.Floor( max );
				max.Ceil( tmp );
			}

			var radio = 1.0f;
			if ( this._projectionType == Projection.Perspective )
			{
				// Merge with far plane bounds
				radio = this._farDistance/this._nearDistance;
				min.Floor( new Vector3( vpLeft*radio, vpBottom*radio, -this._farDistance ) );
				max.Ceil( new Vector3( vpRight*radio, vpTop*radio, 0 ) );
			}

			this._boundingBox.SetExtents( min, max );

			this._recalculateFrustum = false;

			// Signal to update frustum clipping planes
			this._recalculateFrustumPlanes = true;
		}
开发者ID:ryan-bunker,项目名称:axiom3d,代码行数:101,代码来源:Frustum.cs

示例10: intersects

		/* Test if a scene node intersected a portal during the last time delta
			* (from last frame time to current frame time).  This function checks
			* if the node "crossed over" the portal also.
		*/
		public PortalIntersectResult intersects( PCZSceneNode pczsn )
		{
			// Only check if portal is open
			if ( mOpen )
			{
				if ( pczsn == mNode )
				{
					// ignore the scene node if it is the node the portal is associated with
					return PortalIntersectResult.NO_INTERSECT;
				}
				// most complicated case - if the portal is a quad:
				if ( mType == PORTAL_TYPE.PORTAL_TYPE_QUAD )
				{
					// the node is modeled as a line segment (prevPostion to currentPosition)
					// intersection test is then between the capsule and the line segment.
					Segment nodeSegment = new Segment();
					nodeSegment.Set( pczsn.PreviousPosition, pczsn.DerivedPosition );

					// we model the portal as a line swept sphere (mPrevDerivedCP to mDerivedCP).
					Capsule portalCapsule = new Capsule();
					portalCapsule.Set( mPrevDerivedCP, mDerivedCP, mRadius );

					if ( portalCapsule.Intersects( nodeSegment ) )
					{
						// the portal intersected the node at some time from last frame to this frame.
						// Now check if node "crossed" the portal
						// a crossing occurs if the "side" of the final position of the node compared
						// to the final position of the portal is negative AND the initial position
						// of the node compared to the initial position of the portal is non-negative
						if ( mDerivedPlane.GetSide( pczsn.DerivedPosition ) == PlaneSide.Negative &&
							mPrevDerivedPlane.GetSide( pczsn.DerivedPosition ) != PlaneSide.Negative )
						{
							// safety check - make sure the node has at least one dimension which is
							// small enough to fit through the portal! (avoid the "elephant fitting
							// through a mouse hole" case)
							Vector3 nodeHalfVector = pczsn.WorldAABB.HalfSize;
							Vector3 portalBox = new Vector3( mRadius, mRadius, mRadius );
							portalBox.Floor( nodeHalfVector );
							if ( portalBox.x < mRadius )
							{
								// crossing occurred!
								return PortalIntersectResult.INTERSECT_CROSS;
							}
						}
					}
					// there was no crossing of the portal by the node, but it might be touching
					// the portal.  We check for this by checking the bounding box of the node vs.
					// the sphere of the portal
					if ( mDerivedSphere.Intersects( pczsn.WorldAABB ) &&
						mDerivedPlane.GetSide( pczsn.WorldAABB ) == PlaneSide.Both )
					{
						// intersection but no crossing
						// note this means that the node is CURRENTLY touching the portal.
						if ( mDerivedPlane.GetSide( pczsn.DerivedPosition ) != PlaneSide.Negative )
						{
							// the node is on the positive (front) or exactly on the CP of the portal
							return PortalIntersectResult.INTERSECT_NO_CROSS;
						}
						else
						{
							// the node is on the negative (back) side of the portal - it might be in the wrong zone!
							return PortalIntersectResult.INTERSECT_BACK_NO_CROSS;
						}
					}
					// no intersection CURRENTLY.  (there might have been an intersection
					// during the time between last frame and this frame, but it wasn't a portal
					// crossing, and it isn't touching anymore, so it doesn't matter.
					return PortalIntersectResult.NO_INTERSECT;
				}
				else if ( mType == PORTAL_TYPE.PORTAL_TYPE_AABB )
				{
					// for aabb's we check if the center point went from being inside to being outside
					// the aabb (or vice versa) for crossing.
					AxisAlignedBox aabb = new AxisAlignedBox( mDerivedCorners[ 0 ], mDerivedCorners[ 1 ] );
					//bool previousInside = aabb.contains(pczsn->getPrevPosition());
					bool currentInside = aabb.Contains( pczsn.DerivedPosition );
					if ( mDirection == Vector3.UnitZ )
					{
						// portal norm is "outward" pointing, look for going from outside to inside
						//if (previousInside == false &&
						if ( currentInside == true )
						{
							return PortalIntersectResult.INTERSECT_CROSS;
						}
					}
					else
					{
						// portal norm is "inward" pointing, look for going from inside to outside
						//if (previousInside == true &&
						if ( currentInside == false )
						{
							return PortalIntersectResult.INTERSECT_CROSS;
						}
					}
					// doesn't cross, but might be touching.  This is a little tricky because we only
					// care if the node aab is NOT fully contained in the portal aabb because we consider
//.........这里部分代码省略.........
开发者ID:WolfgangSt,项目名称:axiom,代码行数:101,代码来源:Portal.cs


注:本文中的Vector3.Floor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。