本文整理汇总了C#中Axiom.Math.Quaternion类的典型用法代码示例。如果您正苦于以下问题:C# Quaternion类的具体用法?C# Quaternion怎么用?C# Quaternion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Quaternion类属于Axiom.Math命名空间,在下文中一共展示了Quaternion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AttachmentPoint
public AttachmentPoint( string name, string parentBone, Quaternion orientation, Vector3 position )
{
this.name = name;
this.parentBone = parentBone;
this.orientation = orientation;
this.position = position;
}
示例2: IndexOf
public override int IndexOf(Quaternion x) {
lock (this.m_root)
return this.m_collection.IndexOf(x);
}
示例3: AttachObjectToBone
/// <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 );
}
示例4: SetSkyBox
/// <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 )
//.........这里部分代码省略.........
示例5: CreateSkyboxPlane
/// <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 );
}
示例6: Camera
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;
}
示例7: CreateTagPointOnBone
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;
}
示例8: Contains
public override bool Contains(Quaternion x) {
return this.m_collection.Contains(x);
}
示例9: CopyTo
public override void CopyTo(Quaternion[] array, int start) {
this.m_collection.CopyTo(array, start);
}
示例10: AddRange
public override int AddRange(Quaternion[] x) {
lock (this.m_root)
return this.m_collection.AddRange(x);
}
示例11: Remove
public override void Remove(Quaternion x) {
lock (this.m_root)
this.m_collection.Remove(x);
}
示例12: Insert
public override void Insert(int pos, Quaternion x) {
lock (this.m_root)
this.m_collection.Insert(pos, x);
}
示例13: _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
}
示例14: MovablePlane
/// <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;
}
示例15: Compose
/// <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;
}