public Vector3 checkNewPosition(Vector3 position, Vector3 direction)
        {
            if (direction.LengthSquared() <= 0.000001f)
                return position;

            if (m_manager == null)
                return position;

            if (m_manager.MainTimer != null)
                m_manager.MainTimer.Watch.Start();

            Vector3 newPos = position + direction;
            if (CurrentNode == null)
            {
                CurrentNode = m_manager.getMeshNode(newPos);
            }
            // maybe a jump or something like that
            Vector3 transitionPosition = position;
            IMeshNode newNode;
            if (CurrentNode == null)
                newNode = null;
            else
                newNode = CurrentNode.nextNode(newPos, out transitionPosition);
            if (newNode != null)
            {
                CurrentNode = newNode;
                Data_Structures.ContainmentType contType = CurrentNode.isAbove(newPos);
                if (contType == Data_Structures.ContainmentType.UNDER_PLANE)
                {
                    return CurrentNode.alter(newPos);
                }
                else if (contType == Data_Structures.ContainmentType.ON_PLANE)
                {
                    // let's walk on the surface
                    direction = CurrentNode.navigate(direction);
                    if (m_manager.MainTimer != null)
                        m_manager.MainTimer.Watch.Stop();
                    return position + direction;
                }
            }
            // this means we left the mesh
            else
            {
                // maybe there is another mesh we can hop onto
                newNode = m_manager.getMeshNode(newPos);
                if (newNode != null)
                {
                    CurrentNode = newNode;
                    if (m_manager.MainTimer != null)
                        m_manager.MainTimer.Watch.Stop();
                    return newPos;
                }
                else
                {
                    if (m_manager.MainTimer != null)
                        m_manager.MainTimer.Watch.Stop();
                    return transitionPosition;
                }
            }
            if (m_manager.MainTimer != null)
                m_manager.MainTimer.Watch.Stop();
            return newPos;
        }
Beispiel #2
0
 public static void SetVisibility(this IMeshNode node, bool isVisible)
 {
     node.IsVisible = isVisible;
 }
 public override void doInitialize()
 {
     base.doInitialize();
     IPosition3D pos3D = Owner.getFirst(typeof(IPosition3D)) as IPosition3D;
     if (pos3D != null)
     {
         CurrentNode = m_manager.getMeshNode(pos3D.Position);
     }
 }