本文整理汇总了C#中Microsoft.Xna.Framework.Quaternion类的典型用法代码示例。如果您正苦于以下问题:C# Quaternion类的具体用法?C# Quaternion怎么用?C# Quaternion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Quaternion类属于Microsoft.Xna.Framework命名空间,在下文中一共展示了Quaternion类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: EnemyDalek
public EnemyDalek()
: base()
{
current = Quaternion.Identity;
from = Quaternion.Identity;
to = Quaternion.Identity;
}
开发者ID:skooter500,项目名称:2-XNA-Daleks-with-a-Camera,代码行数:7,代码来源:EnemyDalek.cs
示例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();
}
开发者ID:robertg,项目名称:Soar,代码行数:28,代码来源:EnemyFrigate.cs
示例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);
}
开发者ID:andrewstrauch,项目名称:The-Scarab-Gauntlet,代码行数:11,代码来源:Quat16.cs
示例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);
}
开发者ID:NatalieWojciechowski,项目名称:Space394,代码行数:28,代码来源:GameCamera.cs
示例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);
}
开发者ID:thormme,项目名称:Chimera,代码行数:18,代码来源:GoalPoint.cs
示例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;
}
开发者ID:NatalieWojciechowski,项目名称:Space394,代码行数:28,代码来源:Turret.cs
示例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;
}
开发者ID:Aryn,项目名称:Mobile-Fortress,代码行数:26,代码来源:Rocket.cs
示例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;
}
开发者ID:kamilk,项目名称:asteroids,代码行数:7,代码来源:Spaceship.cs
示例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);
}
开发者ID:ylyking,项目名称:Myre,代码行数:15,代码来源:QuaternionExtensions.cs
示例10: OBB
public OBB(Vector3 halfDim, Vector3 pos, Quaternion ori)
{
ori_ = ori;
Pos = pos;
HalfDim = halfDim;
CalcMatrix();
}
开发者ID:paranoiacblack,项目名称:xna-animation,代码行数:7,代码来源:OBB.cs
示例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;
}
开发者ID:NinjaSteph,项目名称:SureShot,代码行数:30,代码来源:Camera.cs
示例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");
}
开发者ID:NatalieWojciechowski,项目名称:Space394,代码行数:26,代码来源:HalkAssaultFighter.cs
示例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));
}
开发者ID:Zodge,项目名称:MonoGame,代码行数:27,代码来源:Vector3Test.cs
示例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);
}
开发者ID:tgjones,项目名称:osiris,代码行数:26,代码来源:Sphere.cs
示例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;
}
开发者ID:NatalieWojciechowski,项目名称:Space394,代码行数:32,代码来源:CapitalShip.cs
示例16: GetRotation
private Quaternion GetRotation(Vector3 src, Vector3 dest)
{
src.Normalize();
dest.Normalize();
float d = Vector3.Dot(src, dest);
if (d >= 1f)
{
return Quaternion.Identity;
}
else if (d < (1e-6f - 1.0f))
{
Vector3 axis = Vector3.Cross(Vector3.UnitX, src);
if (axis.LengthSquared() == 0)
{
axis = Vector3.Cross(Vector3.UnitY, src);
}
axis.Normalize();
return Quaternion.CreateFromAxisAngle(axis, MathHelper.Pi);
}
else
{
float s = (float)Math.Sqrt((1 + d) * 2);
float invS = 1 / s;
Vector3 c = Vector3.Cross(src, dest);
Quaternion q = new Quaternion(invS * c, 0.5f * s);
q.Normalize();
return q;
}
}
开发者ID:brunoduartec,项目名称:port-ploobsengine,代码行数:35,代码来源:BoltObject.cs
示例17: LevelPiece
public LevelPiece(Game game, GameplayScreen host, String assetName)
: base(game, host)
{
// TODO: Construct any child components here
modelName = assetName;
position = new Vector3(0f, 0f, 0f);
// DO NOT ADJUST SCALE IN A CONSTRUCTOR
//scale = 50;
m_rotX = 0;
m_rotZ = 0;
//quat = Quaternion.CreateFromAxisAngle(new Vector3(1, 0, 0), (float)Math.PI / 2);
quat = Quaternion.CreateFromAxisAngle(new Vector3(1, 0, 0), 0);
originalRot = quat;
m_rotationOffset = Vector3.Zero;
//effect.TextureEnabled = true;
m_localRotation = Quaternion.CreateFromAxisAngle(new Vector3(0, 1, 0), 0);
m_fScaleX = 1.0f;
m_fScaleY = 1.0f;
m_fScaleZ = 1.0f;
enableCelShading = true;
mixCelWithTexture = false;
celLightColor = Color.SkyBlue.ToVector4();
outlineThickness = 0.000f;
layerTwoSharp = 0.3f;
layerTwoContrib = 0.08f;
}
开发者ID:vu159951,项目名称:xnasuperdragonball,代码行数:27,代码来源:LevelPiece.cs
示例18: CompoundShapeEntry
///<summary>
/// Constructs a new compound shape entry using the volume of the shape as a weight.
///</summary>
///<param name="shape">Shape to use.</param>
///<param name="orientation">Local orientation of the shape.</param>
///<param name="weight">Weight of the entry. This defines how much the entry contributes to its owner
/// for the purposes of center of rotation computation.</param>
public CompoundShapeEntry(EntityShape shape, Quaternion orientation, float weight)
{
orientation.Validate();
LocalTransform = new RigidTransform(orientation);
Shape = shape;
Weight = weight;
}
开发者ID:dsmo7206,项目名称:Lemma,代码行数:14,代码来源:CompoundShape.cs
示例19: FirstPersonCamera
public FirstPersonCamera(Game game)
: base(game)
{
UpdateOrder = 1;
// Initialize camera state.
accumHeadingDegrees = 0.0f;
accumPitchDegrees = 0.0f;
eye = Vector3.Zero;
target = Vector3.Zero;
targetYAxis = Vector3.UnitY;
xAxis = Vector3.UnitX;
yAxis = Vector3.UnitY;
zAxis = Vector3.UnitZ;
viewDir = Vector3.Forward;
acceleration = new Vector3(DEFAULT_ACCELERATION_X, DEFAULT_ACCELERATION_Y, DEFAULT_ACCELERATION_Z);
velocityWalking = new Vector3(DEFAULT_VELOCITY_X, DEFAULT_VELOCITY_Y, DEFAULT_VELOCITY_Z);
velocityRunning = velocityWalking * DEFAULT_RUNNING_MULTIPLIER;
velocity = velocityWalking;
orientation = Quaternion.Identity;
viewMatrix = Matrix.Identity;
rotationSpeed = 0.2f;
PCinput = new SystemInput.PCinput();
// Setup perspective projection matrix.
clientBounds = game.Window.ClientBounds;
float aspect = (float)clientBounds.Width / (float)clientBounds.Height;
Perspective(DEFAULT_FOVX, aspect, DEFAULT_ZNEAR, DEFAULT_ZFAR);
direction = new Vector3();
smoothedMouseMovement = new Vector2();
}
开发者ID:fqlx,项目名称:SpaceGame,代码行数:34,代码来源:FirstPersonCamera.cs
示例20: Bone
public Bone(FileReader Reader, int Index)
{
BoneIndex = Index;
Reader.ReadUInt32(); //Unknown
Name = Reader.ReadPascalString();
ParentName = Reader.ReadPascalString();
HasPropertyList = (Reader.ReadByte() != 0) ? true : false;
if(HasPropertyList)
{
uint PropertyCount = Reader.ReadUInt32();
for (int i = 0; i < PropertyCount; i++)
PropertyList.Add(new Property(Reader));
}
Translation = new Vector3(Reader.ReadFloat(), Reader.ReadFloat(), Reader.ReadFloat());
Rotation = new Quaternion(Reader.ReadFloat(), -Reader.ReadFloat(), -Reader.ReadFloat(), Reader.ReadFloat());
CanTranslate = (Reader.ReadUInt32() != 0) ? true : false;
CanRotate = (Reader.ReadUInt32() != 0) ? true : false;
CanBlend = (Reader.ReadUInt32() != 0) ? true : false;
//Don Hopkins says the Wiggle parameters are left over from an attempt to use Perlin noise
//introduce some randomness into the animations, so that an animation would look a little different
//each time it was run.
Reader.ReadFloat();
Reader.ReadFloat();
}
开发者ID:Afr0Games,项目名称:Project-Dollhouse,代码行数:29,代码来源:Bone.cs
注:本文中的Microsoft.Xna.Framework.Quaternion类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论