コード例 #1
0
 public EnemyDalek()
     : base()
 {
     current = Quaternion.Identity;
     from = Quaternion.Identity;
     to = Quaternion.Identity;
 }
コード例 #2
0
ファイル: EnemyFrigate.cs プロジェクト: robertg/Soar
        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
0
 /// <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
0
        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
0
ファイル: GoalPoint.cs プロジェクト: thormme/Chimera
 /// <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
0
        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
0
ファイル: Rocket.cs プロジェクト: Aryn/Mobile-Fortress
        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
0
ファイル: Spaceship.cs プロジェクト: kamilk/asteroids
 public Spaceship(ContentManager content)
 {
     model = XNAUtils.LoadModelWithBoundingSphere(ref transforms, ResourceNames.Spaceship, content);
     spacecraftPosition = new Vector3(-1, 1, 5);
     spacecraftRotation = Quaternion.Identity;
     velocity = 0;
 }
コード例 #9
0
ファイル: QuaternionExtensions.cs プロジェクト: ylyking/Myre
        /// <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
0
ファイル: OBB.cs プロジェクト: paranoiacblack/xna-animation
 public OBB(Vector3 halfDim, Vector3 pos, Quaternion ori)
 {
     ori_ = ori;
       Pos = pos;
       HalfDim = halfDim;
       CalcMatrix();
 }
コード例 #11
0
ファイル: Camera.cs プロジェクト: NinjaSteph/SureShot
        /// <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
0
        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
0
ファイル: Vector3Test.cs プロジェクト: Zodge/MonoGame
        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
0
ファイル: Sphere.cs プロジェクト: tgjones/osiris
        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
0
        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;
        }
コード例 #16
0
        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;
            }
        }
コード例 #17
0
        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;
        }
コード例 #18
0
ファイル: CompoundShape.cs プロジェクト: dsmo7206/Lemma
 ///<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;
 }
コード例 #19
0
ファイル: FirstPersonCamera.cs プロジェクト: fqlx/SpaceGame
        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();
        }
コード例 #20
0
ファイル: Bone.cs プロジェクト: Afr0Games/Project-Dollhouse
        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();
        }
コード例 #21
0
ファイル: Bullet.cs プロジェクト: araguzers/Rabies-X
 public Bullet(Vector3 initPos, Quaternion initQRot)
 {
     age = 0;
     position = initPos;
     qRotation = initQRot;
     velocity = new Vector3(0, 0, 400);
 }
コード例 #22
0
        public Interceptor(long _uniqueId, Vector3 _position, Quaternion _rotation, Team _team, SpawnShip _home)
            : base(_uniqueId, _position, _rotation, _team, _home)
        {
            maxZSpeed = 10000.0f;
            minZSpeed = 300.0f;
            normalZSpeed = 500.0f;
            ZSpeed = NormalZSpeed;

            MAX_HEALTH = 3;
            Health = MaxHealth;

            MAX_SHIELDS = 1;
            Shields = MaxShields;

            SHIELD_RECOVER_RATE = 0.2f;

            rollAccel = 10.0f;
            rollBreak = 5.0f;
            rollCap = 2.5f;

            pitchAccel = 7.5f;
            pitchBreak = 5.0f;
            pitchCap = 1.5f;

            yawAccel = 7.5f;
            yawBreak = 5.0f;
            yawCap = 1.5f;

            baseHeat = 0.55f;
            heat = 0;
            overheatHeat = 1.5f;
            heatingRate = 1.5f;
            coolingRate = 0.25f;
            heatDamageRate = 0.1f;
            heatWarningThreshold = 1.2f;
            heatDamageThreshold = 1.4f;

            accelerationRate = 25000.0f;

            FIRE_RATE = 0.1f;
            fireTimer = FireRate;

            SPECIAL_RATE = 0.5f;
            specialTimer = SpecialRate;

            PRIMARY_RANGE = 100000000f;

            CollisionBase = new CollisionSphere(_position, 10);
            CollisionBase.Parent = this;
            CollisionBase.addCollisionEvent(collisionEvent);

            if (ShipTeam == Team.Esxolus)
            {
                ((Sphere)CollisionBase.getPhysicsCollider()).CollisionInformation.CollisionRules.Group = EsxolusShipGroup;
            }
            else
            {
                ((Sphere)CollisionBase.getPhysicsCollider()).CollisionInformation.CollisionRules.Group = HalkShipGroup;
            }
        }
コード例 #23
0
 public static void Write(this ContentWriter contentWriter, Quaternion value)
 {
     contentWriter.Write(value.X);
     contentWriter.Write(value.Y);
     contentWriter.Write(value.Z);
     contentWriter.Write(value.W);
 }
コード例 #24
0
        public Explosion(long _uniqueId, Vector3 _position, Quaternion _rotation)
            : base(_uniqueId, _position, _rotation, "Models/explosion")
        {
            Scale = 1;

            Active = true;

            explosion = ContentLoadManager.loadModel("Models/explosion");

            Random random = new Random((int)(_position.X + _position.Y + _position.Z));
            float x = random.Next() * spinRate; if (random.Next() % 2 == 0) { x *= -1; } else { }
            float y = random.Next() * spinRate; if (random.Next() % 2 == 0) { y *= -1; } else { }
            float z = random.Next() * spinRate; if (random.Next() % 2 == 0) { z *= -1; } else { }

            spinDirection = new Vector3(x, y, z);

            x = random.Next() * outerspinRate; if (random.Next() % 2 == 0) { x *= -1; } else { }
            y = random.Next() * outerspinRate; if (random.Next() % 2 == 0) { y *= -1; } else { }
            z = random.Next() * outerspinRate; if (random.Next() % 2 == 0) { z *= -1; } else { }

            outerSpinDirection = new Vector3(x, y, z);

            float r = (float)random.NextDouble() * MAX_SCALE_RESCALE; if (random.Next() % 2 == 0) { x *= -1; } else { }
            MAX_SCALE += r;

            r = (float)random.NextDouble() * SCALE_RATE_RESCALE; if (random.Next() % 2 == 0) { x *= -1; } else { }
            SCALE_RATE += r;

            generator = new ExplosionParticleGenerator(_position);
        }
コード例 #25
0
ファイル: Camera.cs プロジェクト: alejopelaez/eshcerworld
        /// <summary>
        /// Constructor de la clase camara, se inicializan las matrices y se añaden al effect.
        /// </summary>
        /// <param name="effect">Effecto que se usa para dibujar.</param>
        /// <param name="device">El device actual.</param>
        public Camera(BasicEffect effect, GraphicsDevice device)
        {
            this.effect = effect;
            this.device = device;

            //Angulos inciales de la camara
            angleXZ = MathHelper.Pi / 4;
            angleYZ = MathHelper.Pi / 6;

            yaw = 0;
            pitch = 0;
            roll = 0;

            rotation = Quaternion.Identity;

            //Posicicón y destino inicial de la camara
            posicion.Y = 20 * (float)Math.Sin(angleYZ);
            posicion.X = 20 * (float)Math.Cos(angleYZ) * (float)Math.Sin(angleXZ);
            posicion.Z = 20 * (float)Math.Cos(angleYZ) * (float)Math.Cos(angleXZ);
            destino = new Vector3(0, 0, 0);

            //Se definen las matrices
            setCamera();
            worldMatrix = Matrix.Identity;
            projection = Matrix.CreateOrthographic(device.Viewport.Width / 8, device.Viewport.Height / 8, -200.0f, 200.0f);
            //projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, device.Viewport.AspectRatio, 1.0f, 200.0f);

            //Se añaden al effect
            effect.World = worldMatrix;
            effect.View = viewMatrix;
            effect.Projection = projection;
        }
コード例 #26
0
ファイル: MessageWriter.cs プロジェクト: Aryn/Mobile-Fortress
 public static void ClientEntityCreationMessage(NetConnection c, ushort id, Vector3 position, Quaternion orientation, int nose, int core, int tail, int[] weapons, long ownerID)
 {
     var msg = Network.Server.CreateMessage();
     msg.Write((byte)NetMsgType.CreateOnClient);
     msg.Write((byte)NetEntityType.Ship);
     msg.Write(id);
     msg.Write(position.X); msg.Write(position.Y); msg.Write(position.Z);
     msg.Write(orientation.X); msg.Write(orientation.Y);
     msg.Write(orientation.Z); msg.Write(orientation.W);
         msg.Write(nose);
         msg.Write(core);
         msg.Write(tail);
         if (weapons != null && weapons.Length > 0)
         {
             msg.Write(weapons.Length);
             for (int i = 0; i < weapons.Length; i++)
                 msg.Write(weapons[i]);
         }
         else
         {
             msg.Write((int)0);
         }
     msg.Write(ownerID);
     if (c != null)
         Network.Server.SendMessage(msg, c, NetDeliveryMethod.ReliableOrdered);
     else
         Network.Server.SendToAll(msg, NetDeliveryMethod.ReliableOrdered);
 }
コード例 #27
0
 /// <summary>
 /// Gets the quaternion as an XNA quaternion.
 /// </summary>
 /// <param name="q">The quaternion to receive the data.</param>
 public void Get(out Quaternion q)
 {
     q = new Quaternion((float)X / (float)Constants.MAX_VAL,
             (float)Y / (float)Constants.MAX_VAL,
             (float)Z / (float)Constants.MAX_VAL,
             (float)W / (float)Constants.MAX_VAL);
 }
コード例 #28
0
ファイル: MatrixExtensions.cs プロジェクト: rc183/igf
        public static void GetRotationAndTranslationComponents(this Matrix worldMatrix, out Quaternion rotation, out Vector3 translation)
        {
            worldMatrix.Decompose(out _scale, out _rotation, out _translation);
            rotation = _rotation;
            translation = _translation;

        }
コード例 #29
0
        public static void LookAtLockRotation(Vector3 target, float speed, Vector3 position, ref Quaternion rotation, Vector3 fwd, Vector3 lockedRots)
        {
            LookAt(target, speed, position, ref rotation, fwd);

            LockRotation(ref rotation, lockedRots);

        }
コード例 #30
0
ファイル: PacketWriter.cs プロジェクト: tanis2000/FEZ
 public void Write(Quaternion Value)
 {
   base.Write(Value.X);
   base.Write(Value.Y);
   base.Write(Value.Z);
   base.Write(Value.W);
 }