Example #1
0
        public string RaycastDetectors(Vector3 worldFrom, Vector3 worldTo)
        {
            var invWorld = PositionComp.GetWorldMatrixNormalizedInv();
            var from     = Vector3.Transform(worldFrom, invWorld);
            var to       = Vector3.Transform(worldTo, invWorld);

            BoundingBox unit = new BoundingBox(-Vector3.One, Vector3.One);

            Vector3 localFrom, localTo;

            string result   = null;
            float  distance = float.MaxValue;

            foreach (var group in m_detectors)
            {
                foreach (var det in group.Value)
                {
                    localFrom = Vector3.Transform(from, det);
                    localTo   = Vector3.Transform(to, det);

                    float?dist = unit.Intersects(new Ray(localFrom, localTo));
                    if (dist.HasValue && dist.Value < distance)
                    {
                        distance = dist.Value;
                        result   = group.Key;
                    }
                }
            }

            return(result);
        }
Example #2
0
        public override void UpdateAfterSimulation()
        {
            base.UpdateAfterSimulation();

            if (m_cameraShake != null && m_cameraSpring == null)
            {
                Debug.Assert(CubeGrid != null && CubeGrid.Physics != null, "Grid is null or has no physics!");
                m_cameraSpring = new MyCameraSpring(CubeGrid.Physics);
            }

            if (m_cameraShake != null && m_cameraSpring != null)
            {
                m_cameraSpring.Update(MyEngineConstants.UPDATE_STEP_SIZE_IN_SECONDS, PositionComp.GetWorldMatrixNormalizedInv(), ref m_playerHeadSpring);
                m_cameraShake.UpdateShake(MyEngineConstants.UPDATE_STEP_SIZE_IN_SECONDS, ref m_playerHeadSpring, ref m_playerHeadShakeDir);
            }
        }
Example #3
0
 VRageMath.MatrixD IMyEntity.GetWorldMatrixNormalizedInv()
 {
     return(PositionComp.GetWorldMatrixNormalizedInv());
 }