public override void UpdateShape(VInt3 location, VInt3 forward)
    {
        VCollisionSphere.UpdatePosition(ref this.worldPos, ref this.localPos, ref location, ref forward);
        if (this.rotation != 0)
        {
            forward = forward.RotateY(this.rotation);
        }
        VFactor vFactor;
        VFactor vFactor2;

        IntMath.sincos(out vFactor, out vFactor2, (long)(314 * Mathf.Clamp(this.degree, 1, 360)), 36000L);
        long num  = vFactor2.nom * vFactor.den;
        long num2 = vFactor2.den * vFactor.nom;
        long b    = vFactor2.den * vFactor.den;

        this.rightDir.x = (int)IntMath.Divide((long)forward.x * num + (long)forward.z * num2, b);
        this.rightDir.z = (int)IntMath.Divide((long)(-(long)forward.x) * num2 + (long)forward.z * num, b);
        this.rightDir.y = 0;
        num2            = -num2;
        this.leftDir.x  = (int)IntMath.Divide((long)forward.x * num + (long)forward.z * num2, b);
        this.leftDir.z  = (int)IntMath.Divide((long)(-(long)forward.x) * num2 + (long)forward.z * num, b);
        this.leftDir.y  = 0;
        this.rightDir.Normalize();
        this.leftDir.Normalize();
        this.dirty = false;
    }
Example #2
0
    /// <summary>
    /// 球形插值
    /// </summary>
    /// <param name="start"></param>
    /// <param name="end"></param>
    /// <param name="percent"></param>
    /// <returns></returns>
    public static VInt3 Slerp(VInt3 start, VInt3 end, VFactor percent)
    {
        if (percent == VFactor.zero)
        {
            return(start);
        }
        else if (percent == VFactor.one)
        {
            return(end);
        }

        long den = start.magnitude * end.magnitude;

        VFactor dot = new VFactor((long)Dot(ref start, ref end), den);

        VFactor angle = IntMath.acos(dot.nom, dot.den);

        VFactor theta = angle * percent;

        VInt3 RelativeVec = end - start * dot;

        RelativeVec.NormalizeTo(Precision);

        VFactor sin_theta, cos_thera;

        IntMath.sincos(out sin_theta, out cos_thera, theta);

        return(start * cos_thera + RelativeVec * sin_theta);
    }
Example #3
0
    /// <summary>
    /// 取得点旋转对应角度后的值
    /// </summary>
    /// <param name="degree"></param>
    /// <returns></returns>
    public VInt2 Rotate(int degree)
    {
        VInt2   num;
        VFactor factor;
        VFactor factor2;

        IntMath.sincos(out factor, out factor2, (long)(0x7ab8 * degree), 0x1b7740L);
        long num2 = factor2.nom * factor.den;
        long num3 = factor2.den * factor.nom;
        long b    = factor2.den * factor.den;

        num.x = (int)IntMath.Divide((long)((x * num2) + (y * num3)), b);
        num.y = (int)IntMath.Divide((long)((-x * num3) + (y * num2)), b);
        return(num);
    }
Example #4
0
    public VInt3 RotateY(int degree)
    {
        VFactor vFactor;
        VFactor vFactor2;

        IntMath.sincos(out vFactor, out vFactor2, (long)(31416 * degree), 1800000L);
        long  num  = vFactor2.nom * vFactor.den;
        long  num2 = vFactor2.den * vFactor.nom;
        long  b    = vFactor2.den * vFactor.den;
        VInt3 vInt;

        vInt.x = (int)IntMath.Divide((long)this.x * num + (long)this.z * num2, b);
        vInt.z = (int)IntMath.Divide((long)(-(long)this.x) * num2 + (long)this.z * num, b);
        vInt.y = 0;
        return(vInt.NormalizeTo(1000));
    }
Example #5
0
    public VInt3 RotateY(ref VFactor radians)
    {
        VFactor vFactor;
        VFactor vFactor2;

        IntMath.sincos(out vFactor, out vFactor2, radians.nom, radians.den);
        long  num  = vFactor2.nom * vFactor.den;
        long  num2 = vFactor2.den * vFactor.nom;
        long  b    = vFactor2.den * vFactor.den;
        VInt3 vInt;

        vInt.x = (int)IntMath.Divide((long)this.x * num + (long)this.z * num2, b);
        vInt.z = (int)IntMath.Divide((long)(-(long)this.x) * num2 + (long)this.z * num, b);
        vInt.y = 0;
        return(vInt.NormalizeTo(1000));
    }
Example #6
0
File: Int3.cs Project: end1220/xlab
    public Int3 RotateY(int degree)
    {
        Int3    num;
        VFactor factor;
        VFactor factor2;

        IntMath.sincos(out factor, out factor2, (long)(0x7ab8 * degree), 0x1b7740L);
        long num2 = factor2.nom * factor.den;
        long num3 = factor2.den * factor.nom;
        long b    = factor2.den * factor.den;

        num.x = (int)IntMath.Divide((long)((this.x * num2) + (this.z * num3)), b);
        num.z = (int)IntMath.Divide((long)((-this.x * num3) + (this.z * num2)), b);
        num.y = 0;
        return(num.NormalizeTo(1000));
    }
Example #7
0
File: Int3.cs Project: end1220/xlab
    public Int3 RotateY(ref VFactor radians)
    {
        Int3    num;
        VFactor factor;
        VFactor factor2;

        IntMath.sincos(out factor, out factor2, radians.nom, radians.den);
        long num2 = factor2.nom * factor.den;
        long num3 = factor2.den * factor.nom;
        long b    = factor2.den * factor.den;

        num.x = (int)IntMath.Divide((long)((this.x * num2) + (this.z * num3)), b);
        num.z = (int)IntMath.Divide((long)((-this.x * num3) + (this.z * num2)), b);
        num.y = 0;
        return(num.NormalizeTo(1000));
    }
Example #8
0
    public Int3 RotateY(int degree)
    {
        IntFactor IntVectorFactor;
        IntFactor IntVectorFactor2;

        IntMath.sincos(out IntVectorFactor, out IntVectorFactor2, (long)(31416 * degree), 1800000L);
        long num  = IntVectorFactor2.numerator * IntVectorFactor.denominator;
        long num2 = IntVectorFactor2.denominator * IntVectorFactor.numerator;
        long b    = IntVectorFactor2.denominator * IntVectorFactor.denominator;
        Int3 vInt;

        vInt.x = (int)IntMath.Divide((long)this.x * num + (long)this.z * num2, b);
        vInt.z = (int)IntMath.Divide((long)(-(long)this.x) * num2 + (long)this.z * num, b);
        vInt.y = 0;
        return(vInt.NormalizeTo(1000));
    }
Example #9
0
    public Int3 RotateY(ref IntFactor radians)
    {
        IntFactor IntVectorFactor;
        IntFactor IntVectorFactor2;

        IntMath.sincos(out IntVectorFactor, out IntVectorFactor2, radians.numerator, radians.denominator);
        long num  = IntVectorFactor2.numerator * IntVectorFactor.denominator;
        long num2 = IntVectorFactor2.denominator * IntVectorFactor.numerator;
        long b    = IntVectorFactor2.denominator * IntVectorFactor.denominator;
        Int3 vInt;

        vInt.x = (int)IntMath.Divide((long)this.x * num + (long)this.z * num2, b);
        vInt.z = (int)IntMath.Divide((long)(-(long)this.x) * num2 + (long)this.z * num, b);
        vInt.y = 0;
        return(vInt.NormalizeTo(1000));
    }
Example #10
0
    private VQuaternion(int pitch, int yaw, int roll)
    {
        yaw   /= 2;
        pitch /= 2;
        roll  /= 2;

        VFactor c1, c2, c3, s1, s2, s3;

        IntMath.sincos(out s1, out c1, new VFactor(yaw, Precision) * VFactor.pi / 180L);
        IntMath.sincos(out s2, out c2, new VFactor(pitch, Precision) * VFactor.pi / 180L);
        IntMath.sincos(out s3, out c3, new VFactor(roll, Precision) * VFactor.pi / 180L);

        w = ((c1 * c2 * c3 - s1 * s2 * s3) * Precision).integer;
        x = ((s1 * s2 * c3 + c1 * c2 * s3) * Precision).integer;
        y = ((s1 * c2 * c3 + c1 * s2 * s3) * Precision).integer;
        z = ((c1 * s2 * c3 - s1 * c2 * s3) * Precision).integer;
    }
        public void ProcessInner(Action _action, Track _track, int delta)
        {
            if (this.MoveType == ActorMoveType.RotateBody)
            {
                int   num  = this.rotateBodyDegreeSpeed * delta / 1000;
                VInt3 vInt = this.moveActor.handle.forward.RotateY(-num);
                this.moveActor.handle.forward     = vInt;
                this.moveActor.handle.rotation    = Quaternion.LookRotation((Vector3)vInt);
                this.rotateBodyCurDirDegreeAngle += num;
                this.rotateBodyCurDirDegreeAngle %= 360;
                long    nom = (long)((float)this.rotateBodyCurDirDegreeAngle * 0.0174532924f * 1000f);
                VFactor f;
                VFactor f2;
                IntMath.sincos(out f, out f2, nom, 1000L);
                this.destPosition.x            = this.originateActor.handle.location.x + this.rotateBodyRadius * f2;
                this.destPosition.y            = this.rotateBodyHeight;
                this.destPosition.z            = this.originateActor.handle.location.z + this.rotateBodyRadius * f;
                this.moveDirection             = this.destPosition - this.moveActor.handle.location;
                this.lerpDirection             = this.moveDirection;
                this.moveActor.handle.location = this.destPosition;
            }
            else
            {
                VInt3 location = this.moveActor.handle.location;
                if (this.MoveType == ActorMoveType.Target && this.tarActor)
                {
                    this.destPosition = this.tarActor.handle.location;
                    if (this.tarActor && this.tarActor.handle.CharInfo != null)
                    {
                        CActorInfo charInfo = this.tarActor.handle.CharInfo;
                        this.hitHeight = charInfo.iBulletHeight;
                        VInt3 a = this.moveActor.handle.location - this.destPosition;
                        a.y = 0;
                        a   = a.NormalizeTo(1000);
                        this.destPosition += IntMath.Divide(a, (long)charInfo.iCollisionSize.x, 1000L);
                    }
                    this.destPosition.y = this.destPosition.y + this.hitHeight;
                }
                if (this.bMoveOnXAxis)
                {
                    this.moveDirection = this.destPosition - this.zCurPosition;
                }
                else
                {
                    this.moveDirection = this.destPosition - location;
                }
                this.lerpDirection = this.moveDirection;
                if (this.bMoveRotate && !this.bMoveOnXAxis)
                {
                    this.RotateMoveBullet(this.moveDirection);
                }
                int num2;
                if (!this.shouldUseAcceleration)
                {
                    num2 = this.velocity * delta / 1000;
                }
                else
                {
                    long num3 = (long)this.lastVelocity * (long)delta + (long)this.acceleration * (long)delta * (long)delta / 2L / 1000L;
                    num3 /= 1000L;
                    num2  = (int)num3;
                    this.lastVelocity += this.acceleration * delta / 1000;
                }
                if ((long)num2 * (long)num2 >= this.moveDirection.sqrMagnitudeLong2D && this.bReachDestStop)
                {
                    int magnitude2D = (this.destPosition - this.moveActor.handle.location).magnitude2D;
                    if (this.bMoveOnXAxis)
                    {
                        this.destPosition += this.xDestPosition;
                    }
                    this.moveActor.handle.location = this.destPosition;
                    this.stopCondtion = true;
                    if (this.moveActor.handle.TheActorMeta.ActorType == ActorTypeDef.Actor_Type_Bullet)
                    {
                        BulletWrapper bulletWrapper = this.moveActor.handle.ActorControl as BulletWrapper;
                        if (bulletWrapper != null && bulletWrapper.GetMoveCollisiong())
                        {
                            bulletWrapper.SetMoveDelta(magnitude2D);
                        }
                    }
                }
                else
                {
                    VInt3 vInt2;
                    if (this.gravity < 0)
                    {
                        this.moveDirection.y = 0;
                        vInt2    = location + this.moveDirection.NormalizeTo(num2);
                        vInt2.y += this.gravityControler.GetMotionDeltaDistance(delta);
                        VInt vInt3;
                        if (PathfindingUtility.GetGroundY(this.destPosition, out vInt3) && vInt2.y < vInt3.i)
                        {
                            vInt2.y = vInt3.i;
                        }
                    }
                    else
                    {
                        vInt2 = location + this.moveDirection.NormalizeTo(num2);
                    }
                    if (this.bMoveOnXAxis)
                    {
                        this.zCurPosition += this.moveDirection.NormalizeTo(num2);
                        int   motionDeltaDistance = this.xControler.GetMotionDeltaDistance(delta);
                        VInt3 vInt4 = this.xDirection;
                        vInt4.NormalizeTo(Math.Abs(motionDeltaDistance));
                        if (motionDeltaDistance < 0)
                        {
                            vInt4 = -vInt4;
                        }
                        vInt2 += vInt4;
                        if (this.bMoveRotate)
                        {
                            VInt3 dir = vInt2 - location;
                            this.RotateMoveBullet(dir);
                        }
                    }
                    if (this.moveActor.handle.TheActorMeta.ActorType == ActorTypeDef.Actor_Type_Bullet)
                    {
                        BulletWrapper bulletWrapper2 = this.moveActor.handle.ActorControl as BulletWrapper;
                        if (bulletWrapper2 != null && bulletWrapper2.GetMoveCollisiong())
                        {
                            bulletWrapper2.SetMoveDelta(num2);
                        }
                    }
                    this.moveActor.handle.location = vInt2;
                }
            }
            SkillUseContext refParamObject = _action.refParams.GetRefParamObject <SkillUseContext>("SkillContext");

            if (refParamObject != null)
            {
                refParamObject.EffectPos = this.moveActor.handle.location;
                refParamObject.EffectDir = this.moveDirection;
            }
        }
        private void ActionMoveLerp(ActorRoot actor, uint nDelta, bool bReset)
        {
            if (actor == null || this.stopCondtion || this.stopLerpCondtion)
            {
                return;
            }
            Vector3 vector = Vector3.one;

            if (this.MoveType == ActorMoveType.RotateBody)
            {
                int num = this.rotateBodyDegreeSpeed * (int)nDelta / 1000;
                this.lerpRotateBodyCurDirDegreeAngle += num;
                this.lerpRotateBodyCurDirDegreeAngle %= 360;
                long    nom = (long)((float)this.lerpRotateBodyCurDirDegreeAngle * 0.0174532924f * 1000f);
                VFactor f;
                VFactor f2;
                IntMath.sincos(out f, out f2, nom, 1000L);
                vector.x = this.originateActor.handle.myTransform.position.x + (float)(this.rotateBodyRadius * f2);
                vector.y = (float)this.rotateBodyHeight;
                vector.z = this.originateActor.handle.myTransform.position.z + (float)(this.rotateBodyRadius * f);
            }
            else
            {
                int newMagn;
                if (!this.shouldUseAcceleration)
                {
                    newMagn = this.velocity * (int)nDelta / 1000;
                }
                else
                {
                    long num2 = (long)this.lastLerpVelocity * (long)((ulong)nDelta) + (long)this.acceleration * (long)((ulong)nDelta) * (long)((ulong)nDelta) / 2L / 1000L;
                    num2   /= 1000L;
                    newMagn = (int)num2;
                    this.lastLerpVelocity += (int)((long)this.acceleration * (long)((ulong)nDelta)) / 1000;
                }
                vector = actor.myTransform.position;
                if (this.gravity < 0)
                {
                    this.lerpDirection.y = 0;
                    vector   += (Vector3)this.lerpDirection.NormalizeTo(newMagn);
                    vector.y += (float)this.gravityControler.GetMotionLerpDistance((int)nDelta) / 1000f;
                    VInt ob;
                    if (PathfindingUtility.GetGroundY(this.destPosition, out ob) && vector.y < (float)ob)
                    {
                        vector.y = (float)ob;
                    }
                }
                else
                {
                    vector += (Vector3)this.lerpDirection.NormalizeTo(newMagn);
                }
                if (this.bMoveOnXAxis)
                {
                    int   motionLerpDistance = this.xControler.GetMotionLerpDistance((int)nDelta);
                    VInt3 vInt = this.xDirection;
                    vInt.NormalizeTo(Math.Abs(motionLerpDistance));
                    if (motionLerpDistance < 0)
                    {
                        vInt = -vInt;
                    }
                    vector += (Vector3)vInt;
                }
            }
            actor.myTransform.position = vector;
        }