Exemplo n.º 1
0
        public LuaTable GetInteractingObjects(Mesh target)
        {
            var result = new List<object>();
            var objList = SceneManager.GetGameObjects();

            foreach (var obj in objList)
            {
                if (obj.GetType().Equals(typeof(Mesh)))
                {
                    if (!((Mesh)obj).Equals(target))
                    {
                        if (target.InteractsWith((Mesh)obj))
                        {
                            result.Add(obj);
                        }
                    }
                }
                else if (obj.GetType().Equals(typeof(Trigger)))
                {
                    if (target.InteractsWith((Trigger)obj))
                    {
                        result.Add(obj);
                    }
                }
            }

            return ScriptManager.ListToTable(result);
        }
Exemplo n.º 2
0
        public LuaTable GetInteractingTriggers(Mesh target)
        {
            var result = new List<object>();
            var triggers = from t in SceneManager.GetGameObjects()
                           where t.GetType().Equals(typeof(Trigger))
                           select t;

            foreach (Trigger trigger in triggers)
            {
                if (target.InteractsWith(trigger))
                {
                    result.Add(trigger);
                }
            }

            return ScriptManager.ListToTable(result);
        }
Exemplo n.º 3
0
 public bool InteractsWith(Mesh target)
 {
     TV_3DVECTOR meshBBoxMin = new TV_3DVECTOR();
     TV_3DVECTOR meshBBoxMax = new TV_3DVECTOR();
     TV_3DVECTOR targetBBoxMin = new TV_3DVECTOR();
     TV_3DVECTOR targetBBoxMax = new TV_3DVECTOR();
     mesh.GetBoundingBox(ref meshBBoxMin, ref meshBBoxMax);
     target.GetMesh().GetBoundingBox(ref targetBBoxMin, ref targetBBoxMax);
     return (meshBBoxMin.x < targetBBoxMax.x) &&
         (meshBBoxMax.x > targetBBoxMin.x) &&
         (meshBBoxMin.y < targetBBoxMax.y) &&
         (meshBBoxMax.y > targetBBoxMin.y) &&
         (meshBBoxMin.z < targetBBoxMax.z) &&
         (meshBBoxMax.z > targetBBoxMin.z);
 }