Пример #1
0
        public bool Intersects(AxisAlignedBoxCollider box)
        {
            var center = Object.GlobalTransform.TranslationVector;
            var otherCenter = box.Object.GlobalTransform.TranslationVector;

            if (Math.Abs(center.X - otherCenter.X) > (RadiusWidth + box.RadiusWidth)) return false;
            if (Math.Abs(center.Y - otherCenter.Y) > (RadiusHeight + box.RadiusHeight)) return false;
            if (Math.Abs(center.Z - otherCenter.Z) > (RadiusDepth + box.RadiusDepth)) return false;
            return true;
        }
Пример #2
0
        void CreateBody(Device device, Texture texture)
        {
            _sizeContainer = Add(new GameObject());

            // Container vai ser rotacionado no plano xz para olhar na direção do movimento
            var container = _sizeContainer.Add(new GameObject {
                (_collider = new Components.AxisAlignedBoxCollider { Object = this })
                //new Behaviors.LookForward()
            });

            // Body container poderá rotacionar no seu eixo X, sem que a direção seja impactada
            var bodyContainer = container.Add(new GameObject());
            //.add(Behaviors.RotateWhileJumping, { speed: 6 });
            bodyContainer.Translate(0, 0.1f, 0);

            _body = bodyContainer.Add(new GameObject());
            _body.Translate(0, -0.5f - bodyContainer.Transform.TranslationVector.Y, 0);

            var xAxis = new Vector3(1, 0, 0);

            AddHead(device, texture);
            AddCap(device, texture);
            AddChest(device, texture);
            AddArm(device, texture, new Vector3(-0.35f, 0.05f, 0f))
                .Add(new SwingWhileMoving(xAxis) { Inverse = true });
            AddArm(device, texture, new Vector3(0.35f, 0.05f, 0f))
                .Add(new SwingWhileMoving(xAxis));
            AddLeg(device, texture, new Vector3(-0.125f, -0.35f, 0f))
                .Add(new SwingWhileMoving(xAxis));
            AddLeg(device, texture, new Vector3(0.125f, -0.35f, 0f))
                .Add(new SwingWhileMoving(xAxis) { Inverse = true });
        }