本文整理汇总了C#中Microsoft.Xna.Framework.Quaternion类的典型用法代码示例。如果您正苦于以下问题:C# Quaternion类的具体用法?C# Quaternion怎么用?C# Quaternion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Quaternion类属于Microsoft.Xna.Framework命名空间,在下文中一共展示了Quaternion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EnemyDalek
public EnemyDalek()
: base()
{
current = Quaternion.Identity;
from = Quaternion.Identity;
to = Quaternion.Identity;
}
示例2: EnemyFrigate
public EnemyFrigate(BasicModel model, CollidableType type, float boundingRadius, Vector3 shipPosition, Quaternion shipRotation, float minShipSpeed, float maxShipSpeed,
float turningSpeed, float distanceThresholdEnemy, float distanceThresholdFriend, int life, List<WeaponSystem2D> weaponSystemList)
{
ShipPosition = shipPosition;
ShipWorld = Matrix.CreateTranslation(shipPosition);
ShipRotation = shipRotation;
ShipSpeed = 1f;
MinShipSpeed = minShipSpeed;
MaxShipSpeed = maxShipSpeed;
TurningSpeed = turningSpeed;
DistanceThresholdEnemy = distanceThresholdEnemy;
DistanceThresholdFriend = distanceThresholdFriend;
this.CollidableType = type;
this.BoundingSphereRadius = boundingRadius;
IsFrigate = true;
Life = life;
_model = model;
_momentum = 0f;
_shipStopped = true;
_weaponsList = weaponSystemList;
_randomVar = new Random();
}
示例3: Set
/// <summary>
/// Sets the quaternion from an XNA quaternion.
/// </summary>
/// <param name="q">The quaternion to set this to.</param>
public void Set(Quaternion q)
{
X = (short)(q.X * (float)Constants.MAX_VAL);
Y = (short)(q.Y * (float)Constants.MAX_VAL);
Z = (short)(q.Z * (float)Constants.MAX_VAL);
W = (short)(q.W * (float)Constants.MAX_VAL);
}
示例4: GameCamera
public GameCamera(Scene _currentScene, Vector3 _position, Quaternion _rotation, float _aspectRatio)
{
currentScene = _currentScene;
position = _position;
rotation = _rotation;
aspectRatio = _aspectRatio;
up = new Vector3(0, 1, 0);
target = new Vector3();
viewMatrix = Matrix.CreateLookAt(position,
target, up);
projectionMatrix = Matrix.CreatePerspectiveFieldOfView(
MathHelper.ToRadians(45.0f), aspectRatio,
0.1f, VIEW_DEPTH);
viewPort = Space394Game.GameInstance.GraphicsDevice.Viewport;
fourthPort = new Viewport(
Space394Game.GameInstance.DefaultViewPort.Width / 2 + 1,
Space394Game.GameInstance.DefaultViewPort.Height / 2 + 1,
Space394Game.GameInstance.DefaultViewPort.Width / 2 - 1,
Space394Game.GameInstance.DefaultViewPort.Height / 2 - 1);
splitScreen2 = new AutoTexture2D(Space394Game.GameInstance.Content.Load<Texture2D>("Textures\\splitScreen2"), Vector2.Zero);
splitScreen3 = new AutoTexture2D(Space394Game.GameInstance.Content.Load<Texture2D>("Textures\\splitScreen3"), Vector2.Zero);
splitScreen4 = new AutoTexture2D(Space394Game.GameInstance.Content.Load<Texture2D>("Textures\\splitScreen4"), Vector2.Zero);
blackTexture = new AutoTexture2D(Space394Game.GameInstance.Content.Load<Texture2D>("Textures\\blackTexture"), Vector2.Zero);
blackTexture.Width = fourthPort.Width;
blackTexture.Height = fourthPort.Height;
pausedTexture = new AutoTexture2D(Space394Game.GameInstance.Content.Load<Texture2D>("Textures\\pausedTexture"), Vector2.Zero);
}
示例5: GoalPoint
/// <summary>
/// Constructs a new GoalPoint.
/// </summary>
/// <param name="position">The position.</param>
/// <param name="orientation">The orientation.</param>
/// <param name="scale">The amount to scale by.</param>
/// <param name="nextLevel">
/// The name of the next level to load.
/// An invalid name will return to the Main menu.
/// </param>
/// <param name="partType">The part required to pass the level.</param>
public GoalPoint(Vector3 position, Quaternion orientation, Vector3 scale, string nextLevel, Type partType)
: base(new ScrollingTransparentModel("tractorBeam", new Vector2(0.1f, 0.0f)), new Cylinder(position, 1f, scale.Length() * 7.0f))
{
mNextLevel = nextLevel;
PartType = partType;
Scale = new Vector3(1.0f, 5.0f, 1.0f);
}
示例6: Turret
public Turret(long _uniqueId, Vector3 _position, Quaternion _rotation, String _modelFile, Vector3 _fireConeNormal, float _fireConeAngle, Battleship _parent)
: base(_uniqueId, _position, _rotation, _modelFile)
{
Health = MAX_HEALTH;
fireConeNormalVector = _fireConeNormal;
fireConeNormalVector.Normalize(); // Just in case
fireConeAngle = MathHelper.ToRadians(_fireConeAngle);
parent = _parent;
assignedPhase = nextAssignedPhase;
switch (nextAssignedPhase)
{
case activationPhase.first: nextAssignedPhase = activationPhase.second; break;
case activationPhase.second: nextAssignedPhase = activationPhase.third; break;
case activationPhase.third: nextAssignedPhase = activationPhase.first; break;
}
MAX_SLERP = SLERP_SPEED;
Rotation = AdjustRotationNoLimit(Vector3.Backward, fireConeNormalVector, Vector3.Up);
fireTimer = FIRE_TIMER;
detectionSphere = new CollisionSphere(_position, FIRE_RANGE);
detectionSphere.Active = true;
}
示例7: Rocket
public Rocket(RocketData data, Vector3 position, Quaternion orientation)
: base(new Sphere(position, data.HitboxRadius, 5),data.ModelID)
{
Data = data;
float x = (float)(ProjectileData.pRandom.NextDouble() - 0.5f) * data.BulletSpread;
float y = (float)(ProjectileData.pRandom.NextDouble() - 0.5f) * data.BulletSpread;
Quaternion random = Quaternion.CreateFromYawPitchRoll(MathHelper.ToRadians(x), MathHelper.ToRadians(y), 0);
orientation = random * orientation;
Vector3 velocity = Vector3.Transform(new Vector3(0,0,-Data.MuzzleVel), orientation);
Entity.LinearVelocity = velocity;
forwardVel = Data.MuzzleVel;
Entity.Orientation = orientation;
currentFuel = Data.Fuel;
currentLife = Data.Lifetime;
rocketMotor = new SingleEntityLinearMotor(Entity, Entity.Position);
rocketMotor.Settings.Mode = MotorMode.VelocityMotor;
Sector.Redria.Space.Add(rocketMotor);
trackingMotor = new SingleEntityAngularMotor(Entity);
trackingMotor.Settings.Mode = MotorMode.Servomechanism;
trackingMotor.Settings.Servo.MaxCorrectiveVelocity = 1.5f;
trackingMotor.Settings.Servo.Goal = orientation;
Sector.Redria.Space.Add(trackingMotor);
Entity.CollisionInformation.Events.InitialCollisionDetected += Events_InitialCollisionDetected;
}
示例8: Spaceship
public Spaceship(ContentManager content)
{
model = XNAUtils.LoadModelWithBoundingSphere(ref transforms, ResourceNames.Spaceship, content);
spacecraftPosition = new Vector3(-1, 1, 5);
spacecraftRotation = Quaternion.Identity;
velocity = 0;
}
示例9: Nlerp
/// <summary>
/// Normalizing lerp from a to b, shortest path/non constant velocity
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <param name="t"></param>
/// <param name="result"></param>
/// <returns></returns>
public static void Nlerp(this Quaternion a, ref Quaternion b, float t, out Quaternion result)
{
//return Quaternion.Normalize(Quaternion.Lerp(a, b, t));
Quaternion.Lerp(ref a, ref b, t, out result);
Quaternion.Normalize(ref result, out result);
}
示例10: OBB
public OBB(Vector3 halfDim, Vector3 pos, Quaternion ori)
{
ori_ = ori;
Pos = pos;
HalfDim = halfDim;
CalcMatrix();
}
示例11: Camera
/// <summary>
/// Creates a camera with vertical field of view of 45 degrees, 1.0f near clipping plane and
/// 1000f far clipping plane.
/// </summary>
public Camera()
{
translation = new Vector3();
rotation = Quaternion.Identity;
view = Matrix.Identity;
projection = Matrix.Identity;
cameraTransformation = Matrix.Identity;
Vector3 location = translation;
Vector3 target = -Vector3.UnitZ;
Vector3.Transform(ref target, ref cameraTransformation, out target);
Vector3 up = Vector3.UnitY;
Vector3.Transform(ref up, ref cameraTransformation, out up);
Vector3.Subtract(ref up, ref location, out up);
Matrix.CreateLookAt(ref location, ref target, ref up, out view);
fieldOfView = MathHelper.PiOver4;
aspectRatio = State.Width / (float)State.Height;
zNearPlane = 1.0f;
zFarPlane = 1000.0f;
Matrix.CreatePerspectiveFieldOfView(fieldOfView, aspectRatio, zNearPlane, zFarPlane, out projection);
modifyView = false;
modifyProjection = false;
}
示例12: HalkAssaultFighter
public HalkAssaultFighter(long _uniqueId, Vector3 _position, Quaternion _rotation, SpawnShip _home)
: base(_uniqueId, _position, _rotation, Team.Halk, _home)
{
laserOffsets = new Vector3[] {
new Vector3(-3.382f, -2.532f, 59.654f),
new Vector3(3.382f, -2.532f, 59.654f)
};
SECONDARY_RANGE = 8000000f;
MAX_SECONDARY_AMMO = 9;
SecondaryAmmo = MaxSecondaryAmmo;
secondaryAttackPositions = new Vector3[] {
new Vector3(0, -4.275f, 11.3f),
};
secondaryAttackForward = new Quaternion[] {
Quaternion.CreateFromAxisAngle(Vector3.Forward, 0f)
};
trailGenerators.Add(new HEngineTrailGenerator(this, new Vector3(-3.004f, 1.722f, -22.46f))); // -12.46f
trailGenerators.Add(new HEngineTrailGenerator(this, new Vector3(-0.475f, 1.413f, -22.46f)));
trailGenerators.Add(new HEngineTrailGenerator(this, new Vector3(-0.992f, 3.3987f, -22.46f)));
trailGenerators.Add(new HEngineTrailGenerator(this, new Vector3(1.229f, 4.355f, -22.46f)));
trailGenerators.Add(new HEngineTrailGenerator(this, new Vector3(2.429f, 2.204f, -22.46f)));
setCloseModelByString("Models/Ships/Halk_Assault");
setFarModelByString("Models/Ships/Halk_Assault");
}
示例13: Transform
public void Transform()
{
// STANDART OVERLOADS TEST
var expectedResult1 = new Vector3(51, 58, 65);
var expectedResult2 = new Vector3(33, -14, -1);
var v1 = new Vector3(1, 2, 3);
var m1 = new Matrix(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
var v2 = new Vector3(1, 2, 3);
var q1 = new Quaternion(2, 3, 4, 5);
Vector3 result1;
Vector3 result2;
Assert.That(expectedResult1, Is.EqualTo(Vector3.Transform(v1, m1)).Using(Vector3Comparer.Epsilon));
Assert.That(expectedResult2, Is.EqualTo(Vector3.Transform(v2, q1)).Using(Vector3Comparer.Epsilon));
// OUTPUT OVERLOADS TEST
Vector3.Transform(ref v1, ref m1, out result1);
Vector3.Transform(ref v2, ref q1, out result2);
Assert.That(expectedResult1, Is.EqualTo(result1).Using(Vector3Comparer.Epsilon));
Assert.That(expectedResult2, Is.EqualTo(result2).Using(Vector3Comparer.Epsilon));
}
示例14: DrawWireframe
public static void DrawWireframe(PrimitiveDrawer primitiveDrawer,
Vector3 cameraPosition, Matrix cameraView, Matrix cameraProjection,
Vector3 center, float radius, Quaternion rotation, Color color)
{
// Draw three orthogonal discs.
Disc.DrawWireframe(primitiveDrawer, cameraPosition, cameraView, cameraProjection, center, Vector3.Normalize(Vector3.Transform(Vector3.Up, rotation)), radius, color, true);
Disc.DrawWireframe(primitiveDrawer, cameraPosition, cameraView, cameraProjection, center, Vector3.Normalize(Vector3.Transform(Vector3.Forward, rotation)), radius, color, true);
Disc.DrawWireframe(primitiveDrawer, cameraPosition, cameraView, cameraProjection, center, Vector3.Normalize(Vector3.Transform(Vector3.Left, rotation)), radius, color, true);
// Draw disc aligned with camera. To do this, first calculate the largest visible cross section using
// the technique described here: http://www.quantimegroup.com/solutions/pages/Article/Article.html
// Solve for dy.
Vector3 cameraToCenter = center - cameraPosition;
float distanceToCenter = cameraToCenter.Length();
float radius2 = radius * radius;
float dy = radius2 / distanceToCenter;
float r = MathUtility.Sqrt(radius2 - (dy * dy));
Vector3 directionToCenter = Vector3.Normalize(cameraToCenter);
Vector3 newCenter = cameraPosition + directionToCenter * (distanceToCenter - dy);
// Disc aligned with camera
Disc.DrawWireframe(primitiveDrawer, cameraPosition, cameraView, cameraProjection,
newCenter, directionToCenter, r, Color.White, false);
}
示例15: CapitalShip
public CapitalShip(long _uniqueId, Vector3 _position, Quaternion _rotation, Team _team)
: base(_uniqueId, _position, _rotation, _team)
{
BOMBERS = 3; // 3;
ASSAULT_FIGHTERS = 3; // 3;
INTERCEPTORS = 3; // 3;
INITIAL_BOMBERS = 9; // 9;
INITIAL_ASSAULT_FIGHTERS = 9; // 9;
INITIAL_INTERCEPTORS = 9; // 9;
MAX_BOMBERS = 96;
MAX_ASSAULT_FIGHTERS = 96;
MAX_INTERCEPTORS = 96;
launchedBombers = 0;
launchedAssaultFighters = 0;
launchedInterceptors = 0;
WAVES_TO_LAUNCH = 30;
wavesLaunched = 0;
MAX_HEALTH = 1000;
Health = MaxHealth;
MAX_SHIELDS = 1000;
Shields = MaxShields;
MAX_ATTACKERS = 5;
Attackable = true;
}