示例#1
0
        public override Contact3D GenerateContact(RigidBody3D rb, float dt)
        {
            //Profiler says this method takes up a lot of processing time (AKA, it's run quite often)
            if (rb as SphereBody != null)
            {
                SphereBody c       = rb as SphereBody;
                Vector3    normal  = rb.Pos - this.Pos;
                float      normLen = normal.Length();
                float      dist    = normLen - (this.radius + c.radius);
                normal /= normLen;
                Vector3 pa = this.Pos + normal * this.radius;
                Vector3 pb = rb.Pos - normal * c.radius;

                return(new Contact3D(normal, dist, this, rb, pa, pb));
            }
            else if (rb as PlaneBody != null)
            {
                PlaneBody pb = rb as PlaneBody;
                return(pb.GenerateContact(this, dt));
            }
            else
            {
                throw new NotImplementedException();
            }
        }
示例#2
0
        public override Contact3D GenerateContact(RigidBody3D rb, float dt)
        {
            if (rb as SphereBody != null)
            {
                SphereBody c    = rb as SphereBody;
                float      dist = DistanceToPoint(c.Pos) - c.Radius;

                Vector3 pointOnPlane = c.Pos - (normal * (dist + c.Radius));
                Vector3 pointOnBall  = c.Pos - (normal * c.Radius);

                return(new Contact3D(normal, dist, this, rb, pointOnPlane, pointOnBall));
            }
            else if (rb as PlaneBody != null)
            {
                return(new Contact3D());
            }
            else
            {
                throw new NotImplementedException();
            }
        }
示例#3
0
 public Player(Vector3 initialPlayerPosition)
 {
     cam = new ThirdPersonCamera(initialPlayerPosition, 1.4f, 1f);
     sphereBody = new SphereBody(initialPlayerPosition, Vector3.Zero, 1f, 0.18f);
 }