Summary description for Quaternion.
Exemplo n.º 1
0
		public AttachmentPoint( string name, string parentBone, Quaternion orientation, Vector3 position )
		{
			this.name = name;
			this.parentBone = parentBone;
			this.orientation = orientation;
			this.position = position;
		}
 public override int IndexOf(Quaternion x) {
     lock (this.m_root)
         return this.m_collection.IndexOf(x);
 }
Exemplo n.º 3
0
		/// <summary>
		///		Attaches another object to a certain bone of the skeleton which this entity uses.
		/// </summary>
		/// <param name="boneName">The name of the bone (in the skeleton) to attach this object.</param>
		/// <param name="sceneObject">Reference to the object to attach.</param>
		/// <param name="offsetOrientation">An adjustment to the orientation of the attached object, relative to the bone.</param>
		public TagPoint AttachObjectToBone( string boneName, MovableObject sceneObject, Quaternion offsetOrientation )
		{
			return AttachObjectToBone( boneName, sceneObject, Quaternion.Identity, Vector3.Zero );
		}
Exemplo n.º 4
0
	    /// <summary>
	    ///		Enables / disables a 'sky box' i.e. a 6-sided box at constant
	    ///		distance from the camera representing the sky.
	    /// </summary>
	    /// <remarks>
	    ///		You could create a sky box yourself using the standard mesh and
	    ///		entity methods, but this creates a plane which the camera can
	    ///		never get closer or further away from - it moves with the camera.
	    ///		(you could create this effect by creating a world box which
	    ///		was attached to the same SceneNode as the Camera too, but this
	    ///		would only apply to a single camera whereas this skybox applies
	    ///		to any camera using this scene manager).
	    ///		<p/>
	    ///		The material you use for the skybox can either contain layers
	    ///		which are single textures, or they can be cubic textures, i.e.
	    ///		made up of 6 images, one for each plane of the cube. See the
	    ///		TextureLayer class for more information.
	    /// </remarks>
	    /// <param name="enable">True to enable the skybox, false to disable it</param>
	    /// <param name="materialName">The name of the material the box will use.</param>
	    /// <param name="distance">Distance in world coordinates from the camera to each plane of the box. </param>
	    /// <param name="drawFirst">
	    ///		If true, the box is drawn before all other
	    ///		geometry in the scene, without updating the depth buffer.
	    ///		This is the safest rendering method since all other objects
	    ///		will always appear in front of the sky. However this is not
	    ///		the most efficient way if most of the sky is often occluded
	    ///		by other objects. If this is the case, you can set this
	    ///		parameter to false meaning it draws <em>after</em> all other
	    ///		geometry which can be an optimisation - however you must
	    ///		ensure that the distance value is large enough that no
	    ///		objects will 'poke through' the sky box when it is rendered.
	    /// </param>
	    /// <param name="orientation">
	    ///		Specifies the orientation of the box. By default the 'top' of the box is deemed to be
	    ///		in the +y direction, and the 'front' at the -z direction.
	    ///		You can use this parameter to rotate the sky if you want.
	    /// </param>
	    ///<param name="groupName"></param>
	    public void SetSkyBox( bool enable,
							   string materialName,
							   float distance,
							   bool drawFirst,
							   Quaternion orientation,
							   string groupName )
		{
			// enable the skybox?
			this.isSkyBoxEnabled = enable;

			if ( enable )
			{
				Material m = (Material)MaterialManager.Instance[ materialName ];

				if ( m == null )
				{
					this.isSkyBoxEnabled = false;
					throw new AxiomException( string.Format( "Could not find skybox material '{0}'", materialName ) );
				}
				// Make sure the material doesn't update the depth buffer
				m.DepthWrite = false;
				// Ensure loaded
				m.Load();

				// ensure texture clamping to reduce fuzzy edges when using filtering
                m.GetTechnique( 0 ).GetPass( 0 ).GetTextureUnitState( 0 ).SetTextureAddressingMode( TextureAddressing.Clamp );

				this.isSkyBoxDrawnFirst = drawFirst;

				if ( this.skyBoxNode == null )
				{
					this.skyBoxNode = this.CreateSceneNode( "SkyBoxNode" );
				}
				else
				{
					this.skyBoxNode.DetachAllObjects();
				}

				// need to create 6 plane entities for each side of the skybox
				for ( int i = 0; i < 6; i++ )
				{
					Mesh planeModel = this.CreateSkyboxPlane( (BoxPlane)i, distance, orientation, groupName );
					string entityName = "SkyBoxPlane" + i;

					if ( this.skyBoxEntities[ i ] != null )
					{
						this.RemoveEntity( this.skyBoxEntities[ i ] );
					}

					// create an entity for this plane
					this.skyBoxEntities[ i ] = CreateEntity( entityName, planeModel.Name );

					// skyboxes need not cast shadows
					this.skyBoxEntities[ i ].CastShadows = false;

					// Have to create 6 materials, one for each frame
					// Used to use combined material but now we're using queue we can't split to change frame
					// This doesn't use much memory because textures aren't duplicated
					Material boxMaterial = (Material)MaterialManager.Instance[ entityName ];

					if ( boxMaterial == null )
					{
						// Create new by clone
						boxMaterial = m.Clone( entityName );
						boxMaterial.Load();
					}
					else
					{
						// Copy over existing
						//must not copy over the name, otherwise the sky box entity will be set to use the origional m material instead of the copy for each entity which each uses a different frame
						m.CopyTo( boxMaterial, false );
						boxMaterial.Load();
					}

					// set the current frame
					boxMaterial.GetTechnique( 0 ).GetPass( 0 ).GetTextureUnitState( 0 ).CurrentFrame = i;

					this.skyBoxEntities[ i ].MaterialName = boxMaterial.Name;

					// Attach to node
					this.skyBoxNode.AttachObject( this.skyBoxEntities[ i ] );
				} // for each plane
			}
		}
Exemplo n.º 5
0
		/// <summary>
		/// 	Utility method for creating the planes of a skybox.
		/// </summary>
		/// <param name="plane"></param>
		/// <param name="distance"></param>
		/// <param name="orientation"></param>
		/// <param name="groupName"></param>
		/// <returns></returns>
		protected Mesh CreateSkyboxPlane( BoxPlane plane, float distance, Quaternion orientation, string groupName )
		{
			Plane p = new Plane();
			string meshName = "SkyboxPlane_";
			Vector3 up = Vector3.Zero;

			// set the distance of the plane
			p.D = distance;

			switch ( plane )
			{
				case BoxPlane.Front:
					p.Normal = Vector3.UnitZ;
					up = Vector3.UnitY;
					meshName += "Front";
					break;
				case BoxPlane.Back:
					p.Normal = -Vector3.UnitZ;
					up = Vector3.UnitY;
					meshName += "Back";
					break;
				case BoxPlane.Left:
					p.Normal = Vector3.UnitX;
					up = Vector3.UnitY;
					meshName += "Left";
					break;
				case BoxPlane.Right:
					p.Normal = -Vector3.UnitX;
					up = Vector3.UnitY;
					meshName += "Right";
					break;
				case BoxPlane.Up:
					p.Normal = -Vector3.UnitY;
					up = Vector3.UnitZ;
					meshName += "Up";
					break;
				case BoxPlane.Down:
					p.Normal = Vector3.UnitY;
					up = -Vector3.UnitZ;
					meshName += "Down";
					break;
			}

			// modify by orientation
			p.Normal = orientation * p.Normal;
			up = orientation * up;

			MeshManager modelMgr = MeshManager.Instance;

			// see if this mesh exists
			Mesh planeModel = (Mesh)modelMgr[ meshName ];

			// trash it if it already exists
			if ( planeModel != null )
			{
				modelMgr.Unload( planeModel );
			}

			float planeSize = distance * 2;

			// create and return the plane mesh
			return modelMgr.CreatePlane( meshName, groupName, p, planeSize, planeSize, 1, 1, false, 1, 1, 1, up );
		}
Exemplo n.º 6
0
		public Camera( string name, SceneManager sceneManager )
			: base( name )
		{
			// Record name & SceneManager
			SceneManager = sceneManager;

			// Init camera location & direction

			// Point down -Z axis
			this.orientation = Quaternion.Identity;
			this.position = Vector3.Zero;

			// Reasonable defaults to camera params
			PolygonMode = PolygonMode.Solid;

			// Init no tracking
			AutoTrackingTarget = null;
			AutoTrackingOffset = Vector3.Zero;

			// default these to 1 so Lod default to normal
			this.sceneLodFactor = this.invSceneLodFactor = 1.0f;

			this.useRenderingDistance = true;


			FieldOfView = (float)System.Math.PI/4.0f;
			Near = 100.0f;
			Far = 100000.0f;
			AspectRatio = 1.33333333333333f;
			ProjectionType = Projection.Perspective;

			//SetFixedYawAxis( true );
			FixedYawAxis = Vector3.UnitY; // Axiom specific

			this.derivedOrientation = Quaternion.Identity;

			InvalidateFrustum();
			InvalidateView();

			ViewMatrix = Matrix4.Zero;
			ProjectionMatrix = Matrix4.Zero;

			parentNode = null;

			isReflected = false;
			isVisible = false;
		}
Exemplo n.º 7
0
		/// <summary>
		///		Updates this lights position.
		/// </summary>
		public virtual void Update()
		{
			if ( this.parentNode != null )
			{
				if ( !this.localTransformDirty
					 && this.parentNode.DerivedOrientation == this.lastParentOrientation
					 && this.parentNode.DerivedPosition == this.lastParentPosition )
				{
				}
				else
				{
					// we are out of date with the scene node we are attached to
					this.lastParentOrientation = this.parentNode.DerivedOrientation;
					this.lastParentPosition = this.parentNode.DerivedPosition;
					this.derivedDirection = this.lastParentOrientation * this.direction;
					this.derivedPosition = ( this.lastParentOrientation * this.position ) + this.lastParentPosition;
				}
			}
			else
			{
				this.derivedPosition = this.position;
				this.derivedDirection = this.direction;
			}

			this.localTransformDirty = false;
		}
Exemplo n.º 8
0
		public TagPoint CreateTagPointOnBone( Bone bone, Quaternion offsetOrientation, Vector3 offsetPosition )
		{
			var tagPoint = new TagPoint( ++this.nextTagPointAutoHandle, this );
			this.tagPointList[ this.nextTagPointAutoHandle ] = tagPoint;

			tagPoint.Translate( offsetPosition );
			tagPoint.Rotate( offsetOrientation );
			tagPoint.SetBindingPose();
			bone.AddChild( tagPoint );

			return tagPoint;
		}
 public override int IndexOf(Quaternion x) {
     return this.m_collection.IndexOf(x);
 }
Exemplo n.º 10
0
 public override bool Contains(Quaternion x) {
     return this.m_collection.Contains(x);
 }
Exemplo n.º 11
0
 public override void CopyTo(Quaternion[] array, int start) {
     this.m_collection.CopyTo(array, start);
 }
Exemplo n.º 12
0
 public override void CopyTo(Quaternion[] array) {
     this.m_collection.CopyTo(array);
 }
Exemplo n.º 13
0
 public override int AddRange(Quaternion[] x) {
     lock (this.m_root)
         return this.m_collection.AddRange(x);
 }
Exemplo n.º 14
0
 public override void Remove(Quaternion x) {
     lock (this.m_root)
         this.m_collection.Remove(x);
 }
Exemplo n.º 15
0
 public override void Insert(int pos, Quaternion x) {
     lock (this.m_root)
         this.m_collection.Insert(pos, x);
 }
Exemplo n.º 16
0
		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
		}
Exemplo n.º 17
0
		public TagPoint CreateTagPointOnBone( Bone bone, Quaternion offsetOrientation )
		{
			return CreateTagPointOnBone( bone, Quaternion.Identity, Vector3.Zero );
		}
Exemplo n.º 18
0
 public override void Remove(Quaternion x) {
     throw new NotSupportedException("This is a Read Only Collection and can not be modified");
 }
Exemplo n.º 19
0
		/// <summary>
		///		Constructor.
		/// </summary>
		/// <param name="name">Name of this plane.</param>
		public MovablePlane( string name )
			: base( name )
		{
			lastTranslate = Vector3.Zero;
			lastRotate = Quaternion.Identity;
			isDirty = true;
		}
Exemplo n.º 20
0
		/// <summary>
		/// Creates a translation Matrix
		/// </summary>
		public static Matrix4 Compose( Vector3 translation, Vector3 scale, Quaternion orientation )
		{
			// Ordering:
			//    1. Scale
			//    2. Rotate
			//    3. Translate

			Matrix3 rot3x3, scale3x3;
			rot3x3 = orientation.ToRotationMatrix();
			scale3x3 = Matrix3.Zero;
			scale3x3.m00 = scale.x;
			scale3x3.m11 = scale.y;
			scale3x3.m22 = scale.z;

			// Set up final matrix with scale, rotation and translation
			Matrix4 result = rot3x3 * scale3x3;
			result.Translation = translation;

			return result;
		}
Exemplo n.º 21
0
		public void Rotate( Quaternion qnorm )
		{
			// Note the order of the mult, i.e. q comes after

			// Normalise the quat to avoid cumulative problems with precision
			qnorm.Normalize();
			this.orientation = qnorm*this.orientation;

			InvalidateView();
		}
Exemplo n.º 22
0
		/// <summary>
		/// Creates an inverse translation Matrix
		/// </summary>
		/// <param name="translation"></param>
		/// <param name="scale"></param>
		/// <param name="orientation"></param>
		/// <returns></returns>
		public static Matrix4 ComposeInverse( Vector3 translation, Vector3 scale, Quaternion orientation )
		{
			// Invert the parameters
			Vector3 invTranslate = -translation;
			Vector3 invScale = new Vector3( 1f / scale.x, 1f / scale.y, 1f / scale.z );
			Quaternion invRot = orientation.Inverse();

			// Because we're inverting, order is translation, rotation, scale
			// So make translation relative to scale & rotation
			invTranslate *= invScale; // scale
			invTranslate = invRot * invTranslate; // rotate

			// Next, make a 3x3 rotation matrix and apply inverse scale
			Matrix3 rot3x3, scale3x3;
			rot3x3 = invRot.ToRotationMatrix();
			scale3x3 = Matrix3.Zero;
			scale3x3.m00 = invScale.x;
			scale3x3.m11 = invScale.y;
			scale3x3.m22 = invScale.z;

			// Set up final matrix with scale, rotation and translation
			Matrix4 result = scale3x3 * rot3x3;
			result.Translation = invTranslate;

			return result;
		}
Exemplo n.º 23
0
		/// <summary>
		///		Generates billboard corners.
		///	 </summary>
		/// <remarks>Billboard param only required for type OrientedSelf</remarks>
		protected virtual void GenerateBillboardAxes( ref Vector3 x, ref Vector3 y, Billboard bb )
		{
			// If we're using accurate facing, recalculate camera direction per BB
			if ( this.accurateFacing &&
				 ( this.billboardType == BillboardType.Point ||
				   this.billboardType == BillboardType.OrientedCommon ||
				   this.billboardType == BillboardType.OrientedSelf ) )
			{
				// cam -> bb direction
				this.camDir = bb.Position - this.camPos;
				this.camDir.Normalize();
			}

			switch ( this.billboardType )
			{
				case BillboardType.Point:
					if ( this.accurateFacing )
					{
						// Point billboards will have 'up' based on but not equal to cameras
						y = this.camQ * Vector3.UnitY;
						x = this.camDir.Cross( y );
						x.Normalize();
						y = x.Cross( this.camDir ); // both normalised already
					}
					else
					{
						// Get camera axes for X and Y (depth is irrelevant)
						x = this.camQ * Vector3.UnitX;
						y = this.camQ * Vector3.UnitY;
					}
					break;

				case BillboardType.OrientedCommon:
					// Y-axis is common direction
					// X-axis is cross with camera direction
					y = this.commonDirection;
					x = this.camDir.Cross( y );
					x.Normalize();
					break;

				case BillboardType.OrientedSelf:
					// Y-axis is direction
					// X-axis is cross with camera direction
					// Scale direction first
					y = bb.Direction;
					x = this.camDir.Cross( y );
					x.Normalize();
					break;

				case BillboardType.PerpendicularCommon:
					// X-axis is up-vector cross common direction
					// Y-axis is common direction cross X-axis
					x = this.commonUpVector.Cross( this.commonDirection );
					y = this.commonDirection.Cross( x );
					break;

				case BillboardType.PerpendicularSelf:
					// X-axis is up-vector cross own direction
					// Y-axis is own direction cross X-axis
					x = this.commonUpVector.Cross( bb.Direction );
					x.Normalize();
					y = bb.Direction.Cross( x ); // both should be normalised
					break;
			}

#if NOT
		// Default behavior is that billboards are in local node space
		// so orientation of camera (in world space) must be reverse-transformed
		// into node space to generate the axes
			Quaternion invTransform = parentNode.DerivedOrientation.Inverse();
			Quaternion camQ = Quaternion.Zero;

			switch (billboardType) {
				case BillboardType.Point:
					// Get camera world axes for X and Y (depth is irrelevant)
					camQ = camera.DerivedOrientation;
						// Convert into billboard local space
						camQ = invTransform * camQ;
					x = camQ * Vector3.UnitX;
					y = camQ * Vector3.UnitY;
					break;
				case BillboardType.OrientedCommon:
					// Y-axis is common direction
					// X-axis is cross with camera direction
					y = commonDirection;
					y.Normalize();
						// Convert into billboard local space
						camQ = invTransform * camQ;
					x = camQ * camera.DerivedDirection.Cross(y);
					x.Normalize();
					break;
				case BillboardType.OrientedSelf:
					// Y-axis is direction
					// X-axis is cross with camera direction
					y = billboard.Direction;
						// Convert into billboard local space
						camQ = invTransform * camQ;
					x = camQ * camera.DerivedDirection.Cross(y);
					x.Normalize();
					break;
				case BillboardType.PerpendicularCommon:
					// X-axis is common direction cross common up vector
					// Y-axis is coplanar with common direction and common up vector
					x = commonDirection.Cross(commonUpVector);
					x.Normalize();
					y = x.Cross(commonDirection);
					y.Normalize();
					break;
				case BillboardType.PerpendicularSelf:
					// X-axis is direction cross common up vector
					// Y-axis is coplanar with direction and common up vector
					x = billboard.Direction.Cross(commonUpVector);
					x.Normalize();
					y = x.Cross(billboard.Direction);
					y.Normalize();
					break;
			}
#endif
		}
Exemplo n.º 24
0
		/// <summary>
		///    Decompose the matrix.
		/// </summary>
		/// <param name="translation"></param>
		/// <param name="scale"></param>
		/// <param name="orientation"></param>
		public void Decompose( out Vector3 translation, out Vector3 scale, out Quaternion orientation )
		{
			scale = Vector3.UnitScale;
			Matrix3 rotation = Matrix3.Identity;
			Vector3 axis = Vector3.Zero;

			axis.x = this.m00;
			axis.y = this.m10;
			axis.z = this.m20;
			scale.x = axis.Normalize(); // Normalize() returns the vector's length before it was normalized
			rotation.m00 = axis.x;
			rotation.m10 = axis.y;
			rotation.m20 = axis.z;

			axis.x = this.m01;
			axis.y = this.m11;
			axis.z = this.m21;
			scale.y = axis.Normalize();
			rotation.m01 = axis.x;
			rotation.m11 = axis.y;
			rotation.m21 = axis.z;

			axis.x = this.m02;
			axis.y = this.m12;
			axis.z = this.m22;
			scale.z = axis.Normalize();
			rotation.m02 = axis.x;
			rotation.m12 = axis.y;
			rotation.m22 = axis.z;

			orientation = Quaternion.FromRotationMatrix( rotation );
			translation = this.Translation;
		}
Exemplo n.º 25
0
		/// <summary>
		///
		/// </summary>
		/// <param name="plane"></param>
		/// <param name="curvature"></param>
		/// <param name="tiling"></param>
		/// <param name="distance"></param>
		/// <param name="orientation"></param>
		/// <param name="groupName"></param>
		/// <returns></returns>
		protected Mesh CreateSkyDomePlane( BoxPlane plane,
										   float curvature,
										   float tiling,
										   float distance,
										   Quaternion orientation,
										   string groupName )
		{
			Plane p = new Plane();
			Vector3 up = Vector3.Zero;
			string meshName = "SkyDomePlane_";

			// set up plane equation
			p.D = distance;

			switch ( plane )
			{
				case BoxPlane.Front:
					p.Normal = Vector3.UnitZ;
					up = Vector3.UnitY;
					meshName += "Front";
					break;
				case BoxPlane.Back:
					p.Normal = -Vector3.UnitZ;
					up = Vector3.UnitY;
					meshName += "Back";
					break;
				case BoxPlane.Left:
					p.Normal = Vector3.UnitX;
					up = Vector3.UnitY;
					meshName += "Left";
					break;
				case BoxPlane.Right:
					p.Normal = -Vector3.UnitX;
					up = Vector3.UnitY;
					meshName += "Right";
					break;
				case BoxPlane.Up:
					p.Normal = -Vector3.UnitY;
					up = Vector3.UnitZ;
					meshName += "Up";
					break;
				case BoxPlane.Down:
					return null;
			}

			// modify orientation
			p.Normal = orientation * p.Normal;
			up = orientation * up;

			// check to see if mesh exists
			MeshManager meshManager = MeshManager.Instance;
			Mesh planeMesh = (Mesh)meshManager[ meshName ];

			// destroy existing
			if ( planeMesh != null )
			{
				meshManager.Unload( planeMesh );
				planeMesh.Dispose();
			}

			// create new
			float planeSize = distance * 2;
			int segments = 16;
			planeMesh =
				meshManager.CreateCurvedIllusionPlane(
					meshName,
					groupName,
					p,
					planeSize,
					planeSize,
					curvature,
					segments,
					segments,
					false,
					1,
					tiling,
					tiling,
					up,
					orientation,
					BufferUsage.DynamicWriteOnly,
					BufferUsage.StaticWriteOnly,
					true,
					true );

			return planeMesh;
		}
Exemplo n.º 26
0
		/// <summary>
		///   TODO: should this replace an existing attachment point with the same name?
		/// </summary>
		/// <param name="name"></param>
		/// <param name="rotation"></param>
		/// <param name="translation"></param>
		/// <returns></returns>
		public virtual AttachmentPoint CreateAttachmentPoint( string name, Quaternion rotation, Vector3 translation )
		{
			var ap = new AttachmentPoint( name, null, rotation, translation );
			this._attachmentPoints.Add( ap );
			return ap;
		}
Exemplo n.º 27
0
		/// <summary>
		/// </summary>
		public void SetSkyDome( bool isEnabled,
								string materialName,
								float curvature,
								float tiling,
								float distance,
								bool drawFirst,
								Quaternion orientation,
								string groupName )
		{
			this.isSkyDomeEnabled = isEnabled;
			if ( isEnabled )
			{
				Material material = (Material)MaterialManager.Instance[ materialName ];

				if ( material == null )
				{
					throw new AxiomException( string.Format( "Could not find skydome material '{0}'", materialName ) );
				}

				// make sure the material doesn't update the depth buffer
				material.DepthWrite = false;
				// ensure loading
				material.Load();

				this.isSkyDomeDrawnFirst = drawFirst;

				// create node
				if ( this.skyDomeNode == null )
				{
					this.skyDomeNode = this.CreateSceneNode( "SkyDomeNode" );
				}
				else
				{
					this.skyDomeNode.DetachAllObjects();
				}

				// set up the dome (5 planes)
				for ( int i = 0; i < 5; ++i )
				{
					Mesh planeMesh = this.CreateSkyDomePlane( (BoxPlane)i, curvature, tiling, distance, orientation, groupName );
					string entityName = String.Format( "SkyDomePlane{0}", i );

					// create entity
					if ( this.skyDomeEntities[ i ] != null )
					{
						this.RemoveEntity( this.skyDomeEntities[ i ] );
					}

					this.skyDomeEntities[ i ] = CreateEntity( entityName, planeMesh.Name );
					this.skyDomeEntities[ i ].MaterialName = material.Name;
					// Sky entities need not cast shadows
					this.skyDomeEntities[ i ].CastShadows = false;

					// attach to node
					this.skyDomeNode.AttachObject( this.skyDomeEntities[ i ] );
				} // for each plane
			}
		}
Exemplo n.º 28
0
		/// <summary>
		/// </summary>
		public Mesh CreateCurvedIllusionPlane( string name, string group, Plane plane, float width, float height, float curvature, int xSegments, int ySegments, bool normals, int texCoordSetCount, float xTiles, float yTiles, Vector3 upVector, Quaternion orientation, BufferUsage vertexBufferUsage, BufferUsage indexBufferUsage, bool vertexShadowBuffer, bool indexShadowBuffer )
		{
			return CreateCurvedIllusionPlane( name, group, plane, width, height, curvature, xSegments, ySegments, normals, texCoordSetCount, xTiles, yTiles, upVector, Quaternion.Identity, BufferUsage.StaticWriteOnly, BufferUsage.StaticWriteOnly, vertexShadowBuffer, indexShadowBuffer, -1 );
		}
Exemplo n.º 29
0
		/// <summary>
		///		Attaches another object to a certain bone of the skeleton which this entity uses.
		/// </summary>
		/// <param name="boneName">The name of the bone (in the skeleton) to attach this object.</param>
		/// <param name="sceneObject">Reference to the object to attach.</param>
		/// <param name="offsetOrientation">An adjustment to the orientation of the attached object, relative to the bone.</param>
		/// <param name="offsetPosition">An adjustment to the position of the attached object, relative to the bone.</param>
		public TagPoint AttachObjectToBone( string boneName, MovableObject sceneObject, Quaternion offsetOrientation,
		                                    Vector3 offsetPosition )
		{
			if ( this.childObjectList.ContainsKey( sceneObject.Name ) )
			{
				throw new AxiomException( "An object with the name {0} is already attached.", sceneObject.Name );
			}

			if ( sceneObject.IsAttached )
			{
				throw new AxiomException( "MovableObject '{0}' is already attached to '{1}'", sceneObject.Name,
				                          sceneObject.ParentNode.Name );
			}

			if ( !HasSkeleton )
			{
				throw new AxiomException( "Entity '{0}' has no skeleton to attach an object to.", name );
			}

			var bone = this.skeletonInstance.GetBone( boneName );
			if ( bone == null )
			{
				throw new AxiomException( "Entity '{0}' does not have a skeleton with a bone named '{1}'.", name, boneName );
			}

			var tagPoint = this.skeletonInstance.CreateTagPointOnBone( bone, offsetOrientation, offsetPosition );

			tagPoint.ParentEntity = this;
			tagPoint.ChildObject = sceneObject;

			AttachObjectImpl( sceneObject, tagPoint );

			// Trigger update of bounding box if necessary
			if ( parentNode != null )
			{
				parentNode.NeedUpdate();
			}

			return tagPoint;
		}
Exemplo n.º 30
0
		/// <summary>
		/// </summary>
		public Mesh CreateCurvedIllusionPlane( string name, string group, Plane plane, float width, float height, float curvature, int xSegments, int ySegments, bool normals, int texCoordSetCount, float xTiles, float yTiles, Vector3 upVector, Quaternion orientation, BufferUsage vertexBufferUsage, BufferUsage indexBufferUsage, bool vertexShadowBuffer, bool indexShadowBuffer, int ySegmentsToKeep )
		{

			// Create manual mesh which calls back self to load
			Mesh mesh = CreateManual( name, group, this );
			// Planes can never be manifold
			mesh.AutoBuildEdgeLists = false;
			// store parameters
			MeshBuildParams meshParams = new MeshBuildParams();
			meshParams.Type = MeshBuildType.Plane;
			meshParams.Plane = plane;
			meshParams.Width = width;
			meshParams.Height = height;
			meshParams.Curvature = curvature;
			meshParams.XSegments = xSegments;
			meshParams.YSegments = ySegments;
			meshParams.Normals = normals;
			meshParams.TexCoordSetCount = texCoordSetCount;
			meshParams.XTile = xTiles;
			meshParams.YTile = yTiles;
			meshParams.Orientation = orientation;
			meshParams.UpVector = upVector;
			meshParams.VertexBufferUsage = vertexBufferUsage;
			meshParams.IndexBufferUsage = indexBufferUsage;
			meshParams.VertexShadowBuffer = vertexShadowBuffer;
			meshParams.IndexShadowBuffer = indexShadowBuffer;
			meshParams.YSegmentsToKeep = ySegmentsToKeep;
			_meshBuildParams.Add( mesh, meshParams );

			// to preserve previous behaviour, load immediately
			mesh.Load();

			return mesh;
		}