예제 #1
0
        protected override void OnFire(Vec3 firePos)
        {
            var muzzleFlash = ParticleEffect.Get("weapon_fx.tank.tank125.muzzle_flash.muzzle_flash");
            muzzleFlash.Spawn(firePos, Attachment.Rotation.Column1, 0.5f);

            Owner.Physics.AddImpulse(-Attachment.Rotation.Column1 * impulseStrength);
        }
예제 #2
0
        public void Equals_EqualVec3Objects_True()
        {
            Vec3 v1 = new Vec3(1, 2, 3);
            Vec3 v2 = new Vec3(1, 2, 3);

            Assert.IsTrue(v1.Equals(v2));
        }
예제 #3
0
        public void NetSpawn(EntityId targetId, Vec3 pos)
        {
            var tank = Entity.Get<Tank>(targetId);

            tank.Position = pos;

            tank.OnRevive();
        }
예제 #4
0
        public void Vec3()
        {
            Vec3 vec3 = UnusedMarker.Vec3;
            Assert.True(UnusedMarker.IsUnused(vec3));

            vec3 = new Vec3(0, 250, 3);
            Assert.False(UnusedMarker.IsUnused(vec3));
        }
예제 #5
0
        public void Launch(Vec3 velocity)
        {
            ReceiveUpdates = true;
            state = BoidState.Launched;

            Physics.AddImpulse(velocity);
            OnLaunched(velocity);
        }
예제 #6
0
        public override void OnRevive(EntityId actorId, Vec3 pos, Vec3 rot, int teamId)
        {
            var player = Actor.Get<Player>(actorId);

            if(player == null)
            {
                Debug.Log("[SinglePlayer.OnRevive] Failed to get the player. Check the log for errors.");
                return;
            }
        }
예제 #7
0
        protected override void OnCollision(EntityId targetEntityId, Vec3 hitPos, Vec3 dir, short materialId, Vec3 contactNormal)
        {
            if(Velocity.Length > VelocityToKill)
            {
                var particle = ParticleEffect.Get("explosions.barrel.explode");
                particle.Spawn(hitPos);

                Entity.Remove(Id);
            }
        }
예제 #8
0
        public override void OnRevive(EntityId actorId, Vec3 pos, Vec3 rot, int teamId)
        {
            var cameraProxy = Actor.Get(actorId) as PlayerCamera;
            if(cameraProxy == null)
            {
                Debug.Log("[SinglePlayer.OnRevive] Failed to get the player proxy. Check the log for errors.");
                return;
            }

            cameraProxy.Init();
        }
예제 #9
0
 protected override void OnCollision(EntityId targetEntityId, Vec3 hitPos, Vec3 dir, short materialId, Vec3 contactNormal)
 {
     // Hit something, reset last event time.
     if(state == BoidState.Launched)
     {
         if(postFire == null)
             postFire = new DelayedFunc(OnStoppedMoving, 4000);
         else
             postFire.Reset();
     }
 }
예제 #10
0
        protected override void OnCollision(EntityId targetEntityId, Vec3 hitPos, Vec3 dir, short materialId, Vec3 contactNormal)
        {
            if (!Destroyed && targetEntityId!=0)
            {
                var breakageParams = new BreakageParameters();
                breakageParams.type = BreakageType.Destroy;
                breakageParams.fParticleLifeTime = 7.0f;
                breakageParams.bMaterialEffects = true;
                breakageParams.nGenericCount = 0;
                breakageParams.bForceEntity = false;
                breakageParams.bOnlyHelperPieces = false;

                breakageParams.fExplodeImpulse = 10.0f;
                breakageParams.vHitImpulse = dir;
                breakageParams.vHitPoint = hitPos;

                Physics.Break(breakageParams);

                SetSlotFlags(GetSlotFlags() | EntitySlotFlags.Render);

                Destroyed = true;
            }
        }
예제 #11
0
파일: QuatT.cs 프로젝트: rookboom/CryMono
 public void SetFromVectors(Vec3 vx, Vec3 vy, Vec3 vz, Vec3 pos)
 {
     var m34 = new Matrix34();
     m34.M00 = vx.X; m34.M01 = vy.X; m34.M02 = vz.X; m34.M03 = pos.X;
     m34.M10 = vx.Y; m34.M11 = vy.Y; m34.M12 = vz.Y; m34.M13 = pos.Y;
     m34.M20 = vx.Z; m34.M21 = vy.Z; m34.M22 = vz.Z; m34.M23 = pos.Z;
     this = new QuatT(m34);
 }
예제 #12
0
파일: Actor.cs 프로젝트: RogierWV/315GR
 /// <summary>
 /// Sent on entity collision.
 /// </summary>
 protected virtual void OnCollision(ColliderInfo source, ColliderInfo target, Vec3 hitPos, Vec3 contactNormal, float penetration, float radius)
 {
 }
예제 #13
0
 /// <summary>
 /// apply scaling to matrix.
 /// </summary>
 /// <returns></returns>
 void Scale(Vec3 s)
 {
     M00 *= s.X; M01 *= s.Y; M02 *= s.Z;
     M10 *= s.X; M11 *= s.Y; M12 *= s.Z;
     M20 *= s.X; M21 *= s.Y; M22 *= s.Z;
 }
예제 #14
0
 /// <summary>
 /// transforms a vector. the translation is not beeing considered
 /// </summary>
 /// <param name="p"></param>
 /// <returns></returns>
 public Vec3 TransformVector(Vec3 p)
 {
     return new Vec3(M00 * p.X + M01 * p.Y + M02 * p.Z + M03, M10 * p.X + M11 * p.Y + M12 * p.Z + M13, M20 * p.X + M21 * p.Y + M22 * p.Z + M23);
 }
예제 #15
0
 public void SetTranslationMat(Vec3 v)
 {
     M00 = 1.0f; M01 = 0.0f; M02 = 0.0f; M03 = v.X;
     M10 = 0.0f; M11 = 1.0f; M12 = 0.0f; M13 = v.Y;
     M20 = 0.0f; M21 = 0.0f; M22 = 1.0f; M23 = v.Z;
 }
예제 #16
0
 public void SetTranslation(Vec3 t)
 {
     M03 = t.X;
     M13 = t.Y;
     M23 = t.Z;
 }
예제 #17
0
 /// <summary>
 /// Normalizes a Vector.
 /// </summary>
 /// <returns>Returning argument multiplied with frametime.</returns>
 /// <param name="value">Absolute value.</param>
 public static Vec3 Normalize(Vec3 value)
 {
     return(value * _frameTime);
 }
예제 #18
0
파일: QuatT.cs 프로젝트: rookboom/CryMono
 public QuatT(Vec3 t, Quat q)
 {
     Q = q;
     T = t;
 }
예제 #19
0
파일: QuatT.cs 프로젝트: rookboom/CryMono
        public void SetRotationXYZ(Vec3 rad, Vec3? trans = null)
        {
            Q.SetRotationXYZ(rad);

            T = trans.GetValueOrDefault();
        }
예제 #20
0
 public static void SetVariableValue(CloudShadingParams param, Vec3 value)
 {
     Native3DEngineMethods.SetTimeOfDayVariableValueColor((int)param, value);
 }
예제 #21
0
파일: QuatT.cs 프로젝트: rookboom/CryMono
 public void Invert()
 {
     T = -T * Q;
     Q = !Q;
 }
예제 #22
0
        public void Length_NormalizedVec3_True()
        {
            Vec3 v = new Vec3(1, 0, 0);

            Assert.IsTrue(v.Length == 1);
        }
예제 #23
0
 public static void SetVariableValue(SunRaysEffectParams param, Vec3 value)
 {
     Native3DEngineMethods.SetTimeOfDayVariableValueColor((int)param, value);
 }
예제 #24
0
 public static Sound CreateLineSound(string name, Vec3 start, Vec3 end)
 {
     return(TryGet(NativeSoundMethods.CreateLineSound(name, 0, 0, start, end)));
 }
예제 #25
0
 public void Normalize_Vec3_LengthIsEqualToOne()
 {
     Vec3 v = new Vec3(26, 23, 135);
     v.Normalize();
     Assert.IsTrue(v.Length == 1);
 }
예제 #26
0
        public void SetRotationAA(Vec3 rot, Vec3 t = default(Vec3))
        {
            this = new Matrix34(Matrix33.CreateRotationAA(rot));

            SetTranslation(t);
        }
예제 #27
0
파일: QuatT.cs 프로젝트: rookboom/CryMono
        /*public bool IsValid()
        {
            if (!T.IsValid()) return false;
            if (!Q.IsValid()) return false;
            return true;
        }*/
        public void Nlerp(QuatT start, QuatT end, float amount)
        {
            var d = end.Q;
            if ((start.Q | d) < 0) { d = -d; }

            var vDiff = d.V - start.Q.V;

            Q.V = start.Q.V + (vDiff * amount);
            Q.W = start.Q.W + ((d.W - start.Q.W) * amount);

            Q.Normalize();

            vDiff = end.T - start.T;
            T = start.T + (vDiff * amount);
        }
예제 #28
0
 public void SetRotationAA(float c, float s, Vec3 axis, Vec3 t = default(Vec3))
 {
     this = new Matrix34(Matrix33.CreateRotationAA(c, s, axis));
     M03 = t.X; M13 = t.Y; M23 = t.Z;
 }
예제 #29
0
파일: QuatT.cs 프로젝트: rookboom/CryMono
 public void SetRotationAA(float cosha, float sinha, Vec3 axis, Vec3? trans = null)
 {
     Q.SetRotationAA(cosha, sinha, axis);
     T = trans.GetValueOrDefault();
 }
예제 #30
0
        /*!
        * Create rotation-matrix about Z axis using an angle.
        * The angle is assumed to be in radians.
        * The translation-vector is set to zero.
        *
        *  Example:
        *        Matrix34 m34;
        *        m34.SetRotationZ(0.5f);
        */
        public void SetRotationZ(float rad, Vec3 t = default(Vec3))
        {
            this = new Matrix34(Matrix33.CreateRotationZ(rad));

            SetTranslation(t);
        }
예제 #31
0
파일: QuatT.cs 프로젝트: rookboom/CryMono
 public void SetTranslation(Vec3 trans)
 {
     T = trans;
 }
예제 #32
0
        public void SetScale(Vec3 s, Vec3 t = default(Vec3))
        {
            this = new Matrix34(Matrix33.CreateScale(s));

            SetTranslation(t);
        }
예제 #33
0
파일: QuatT.cs 프로젝트: rookboom/CryMono
 public QuatT(Matrix34 m)
 {
     Q = new Quat(m);
     T = m.GetTranslation();
 }
예제 #34
0
        /// <summary>
        ///  Direct-Matrix-Slerp: for the sake of completeness, I have included the following expression 
        ///  for Spherical-Linear-Interpolation without using quaternions. This is much faster then converting 
        ///  both matrices into quaternions in order to do a quaternion slerp and then converting the slerped 
        ///  quaternion back into a matrix.
        ///  This is a high-precision calculation. Given two orthonormal 3x3 matrices this function calculates 
        ///  the shortest possible interpolation-path between the two rotations. The interpolation curve forms 
        ///  a great arc on the rotation sphere (geodesic). Not only does Slerp follow a great arc it follows 
        ///  the shortest great arc.    Furthermore Slerp has constant angular velocity. All in all Slerp is the 
        ///  optimal interpolation curve between two rotations. 
        ///  STABILITY PROBLEM: There are two singularities at angle=0 and angle=PI. At 0 the interpolation-axis 
        ///  is arbitrary, which means any axis will produce the same result because we have no rotation. Thats 
        ///  why I'm using (1,0,0). At PI the rotations point away from each other and the interpolation-axis 
        ///  is unpredictable. In this case I'm also using the axis (1,0,0). If the angle is ~0 or ~PI, then we 
        ///  have to normalize a very small vector and this can cause numerical instability. The quaternion-slerp 
        ///  has exactly the same problems.                                                                    Ivo
        /// </summary>
        /// <param name="m"></param>
        /// <param name="n"></param>
        /// <param name="t"></param>
        /// <example>Matrix33 slerp=Matrix33::CreateSlerp( m,n,0.333f );</example>
        public void SetSlerp(Matrix34 m, Matrix34 n, float t)
        {
            // calculate delta-rotation between m and n (=39 flops)
            Matrix33 d = new Matrix33(), i = new Matrix33();
            d.M00 = m.M00 * n.M00 + m.M10 * n.M10 + m.M20 * n.M20; d.M01 = m.M00 * n.M01 + m.M10 * n.M11 + m.M20 * n.M21; d.M02 = m.M00 * n.M02 + m.M10 * n.M12 + m.M20 * n.M22;
            d.M10 = m.M01 * n.M00 + m.M11 * n.M10 + m.M21 * n.M20; d.M11 = m.M01 * n.M01 + m.M11 * n.M11 + m.M21 * n.M21; d.M12 = m.M01 * n.M02 + m.M11 * n.M12 + m.M21 * n.M22;
            d.M20 = d.M01 * d.M12 - d.M02 * d.M11; d.M21 = d.M02 * d.M10 - d.M00 * d.M12; d.M22 = d.M00 * d.M11 - d.M01 * d.M10;

            // extract angle and axis
            double cosine = MathHelpers.Clamp((d.M00 + d.M11 + d.M22 - 1.0) * 0.5, -1.0, +1.0);
            double angle = Math.Atan2(Math.Sqrt(1.0 - cosine * cosine), cosine);
            var axis = new Vec3(d.M21 - d.M12, d.M02 - d.M20, d.M10 - d.M01);
            double l = Math.Sqrt(axis | axis); if (l > 0.00001) axis /= (float)l; else axis = new Vec3(1, 0, 0);
            i.SetRotationAA((float)angle * t, axis); // angle interpolation and calculation of new delta-matrix (=26 flops)

            // final concatenation (=39 flops)
            M00 = m.M00 * i.M00 + m.M01 * i.M10 + m.M02 * i.M20; M01 = m.M00 * i.M01 + m.M01 * i.M11 + m.M02 * i.M21; M02 = m.M00 * i.M02 + m.M01 * i.M12 + m.M02 * i.M22;
            M10 = m.M10 * i.M00 + m.M11 * i.M10 + m.M12 * i.M20; M11 = m.M10 * i.M01 + m.M11 * i.M11 + m.M12 * i.M21; M12 = m.M10 * i.M02 + m.M11 * i.M12 + m.M12 * i.M22;
            M20 = M01 * M12 - M02 * M11; M21 = M02 * M10 - M00 * M12; M22 = M00 * M11 - M01 * M10;

            M03 = m.M03 * (1 - t) + n.M03 * t;
            M13 = m.M13 * (1 - t) + n.M13 * t;
            M23 = m.M23 * (1 - t) + n.M23 * t;
        }