Beispiel #1
0
        int UnityEngineTransform_m_InverseTransformPoint(RealStatePtr L, int gen_param_count)
        {
            ObjectTranslator translator = this;


            UnityEngine.Transform gen_to_be_invoked = (UnityEngine.Transform)translator.FastGetCSObj(L, 1);

            if (gen_param_count == 4 && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2) && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 3) && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 4))
            {
                float _x = (float)LuaAPI.lua_tonumber(L, 2);
                float _y = (float)LuaAPI.lua_tonumber(L, 3);
                float _z = (float)LuaAPI.lua_tonumber(L, 4);

                UnityEngine.Vector3 gen_ret = gen_to_be_invoked.InverseTransformPoint(_x, _y, _z);
                translator.PushUnityEngineVector3(L, gen_ret);



                return(1);
            }
            if (gen_param_count == 2 && translator.Assignable <UnityEngine.Vector3>(L, 2))
            {
                UnityEngine.Vector3 _position; translator.Get(L, 2, out _position);

                UnityEngine.Vector3 gen_ret = gen_to_be_invoked.InverseTransformPoint(_position);
                translator.PushUnityEngineVector3(L, gen_ret);



                return(1);
            }


            return(LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.Transform.InverseTransformPoint!"));
        }
Beispiel #2
0
        public static TriangleHit?Raycast(Ray ray, int level, BoundsMap bounds, Func <Cell, float> heightAt, Transform gridTransform = null)
        {
            if (gridTransform != null)
            {
                ray = new Ray(gridTransform.InverseTransformPoint(ray.origin), gridTransform.InverseTransformDirection(ray.direction));
            }

            var closest    = (ray.origin - Vector3.Dot(ray.origin, ray.direction) * ray.direction).magnitude;
            var candidates = new List <Triangle>(Triangle.AtLevel(0));

            for (int i = 0; i < level; i++)
            {
                var triangles = candidates;
                candidates = new List <Triangle>();
                foreach (var triangle in triangles)
                {
                    var max = bounds.GetMax(triangle, i);
                    if (max < closest)
                    {
                        continue;
                    }

                    if (intersectsCell(ray, triangle, i, bounds.GetMin(triangle, i), max))
                    {
                        candidates.AddRange(triangle.GetChildren(i + 1));
                    }
                }
            }

            return(candidates.Select(t => t.Raycast(ray, level, heightAt)).Where(h => h.HasValue).MinByOrDefault(t => t.Value.Distance));
        }
Beispiel #3
0
        /// <summary>
        /// Generate rigid body transform snapshot for owned transforms with specified timestamp.
        /// </summary>
        /// <param name="time">Snapshot timestamp.</param>
        /// <param name="rootTransform">Root transform.</param>
        /// <returns>Generated snapshot.</returns>
        public Snapshot GenerateSnapshot(float time, UnityEngine.Transform rootTransform)
        {
            // collect transforms from owned rigid bodies
            // and generate update packet/snapshot

            List <Snapshot.TransformInfo> transforms = new List <Snapshot.TransformInfo>(_rigidBodies.Count);

            foreach (var rb in _rigidBodies.Values)
            {
                if (!rb.Ownership)
                {
                    continue;
                }

                RigidBodyTransform transform;
                {
                    transform.Position = rootTransform.InverseTransformPoint(rb.RigidBody.transform.position);
                    transform.Rotation = UnityEngine.Quaternion.Inverse(rootTransform.rotation) * rb.RigidBody.transform.rotation;
                }

                Patching.Types.MotionType mType = (rb.IsKeyframed) ? (Patching.Types.MotionType.Keyframed)
                                        : (Patching.Types.MotionType.Dynamic);

                transforms.Add(new Snapshot.TransformInfo(rb.Id, transform, mType));
#if MRE_PHYSICS_DEBUG
                Debug.Log(" SEND Remote body: " + rb.Id.ToString() + " OriginalRot:" + transform.Rotation
                          + " RigidBodyRot:" + rb.RigidBody.transform.rotation);
#endif
            }

            return(new Snapshot(time, transforms));
        }
Beispiel #4
0
        public static int InverseTransformPoint(IntPtr L)
        {
            int result = 1;
            int count  = LuaDLL.lua_gettop(L);

            if (count == 2 &&
                LuaStatic.CheckType(L, typeof(UnityEngine.Vector3), 2))
            {
                UnityEngine.Transform obj  = LuaStatic.GetObj(L, 1) as UnityEngine.Transform;
                UnityEngine.Vector3   arg1 = (UnityEngine.Vector3)LuaStatic.GetObj(L, 2);
                LuaDLL.lua_pushvector3(L, obj.InverseTransformPoint(arg1));

                return(result);
            }
            if (count == 4 &&
                LuaStatic.CheckType(L, typeof(Single), 2) &&
                LuaStatic.CheckType(L, typeof(Single), 3) &&
                LuaStatic.CheckType(L, typeof(Single), 4))
            {
                UnityEngine.Transform obj = LuaStatic.GetObj(L, 1) as UnityEngine.Transform;
                Single arg1 = (Single)(double)(LuaStatic.GetObj(L, 2));
                Single arg2 = (Single)(double)(LuaStatic.GetObj(L, 3));
                Single arg3 = (Single)(double)(LuaStatic.GetObj(L, 4));
                LuaDLL.lua_pushvector3(L, obj.InverseTransformPoint(arg1, arg2, arg3));

                return(result);
            }
            LuaStatic.traceback(L, "count not enough");
            LuaDLL.lua_error(L);
            return(result);
        }
        static int _m_InverseTransformPoint(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


            UnityEngine.Transform __cl_gen_to_be_invoked = (UnityEngine.Transform)translator.FastGetCSObj(L, 1);


            int __gen_param_count = LuaAPI.lua_gettop(L);

            try {
                if (__gen_param_count == 4 && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2) && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 3) && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 4))
                {
                    float x = (float)LuaAPI.lua_tonumber(L, 2);
                    float y = (float)LuaAPI.lua_tonumber(L, 3);
                    float z = (float)LuaAPI.lua_tonumber(L, 4);

                    UnityEngine.Vector3 __cl_gen_ret = __cl_gen_to_be_invoked.InverseTransformPoint(x, y, z);
                    translator.PushUnityEngineVector3(L, __cl_gen_ret);



                    return(1);
                }
                if (__gen_param_count == 2 && translator.Assignable <UnityEngine.Vector3>(L, 2))
                {
                    UnityEngine.Vector3 position; translator.Get(L, 2, out position);

                    UnityEngine.Vector3 __cl_gen_ret = __cl_gen_to_be_invoked.InverseTransformPoint(position);
                    translator.PushUnityEngineVector3(L, __cl_gen_ret);



                    return(1);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }

            return(LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.Transform.InverseTransformPoint!"));
        }
Beispiel #6
0
    public static int InverseTransformPoint(System.IntPtr L)
    {
        int nargs = LuaAPI.GetTop(L);

        if (nargs == 2 && LuaAPI.IsObject(L, 1) && LuaAPI.IsVector3(L, 2))
        {
            UnityEngine.Transform arg0 = (UnityEngine.Transform)LuaCallback.ToObject(L, 1);
            UnityEngine.Vector3   arg1 = (UnityEngine.Vector3)LuaCallback.ToVector3(L, 2);
            UnityEngine.Vector3   res  = arg0.InverseTransformPoint(arg1);
            LuaCallback.PushVector(L, res);
            return(1);
        }
        if (nargs == 4 && LuaAPI.IsObject(L, 1) && LuaAPI.IsNumber(L, 2) && LuaAPI.IsNumber(L, 3) && LuaAPI.IsNumber(L, 4))
        {
            UnityEngine.Transform arg0 = (UnityEngine.Transform)LuaCallback.ToObject(L, 1);
            System.Single         arg1 = (System.Single)LuaCallback.ToNumber(L, 2);
            System.Single         arg2 = (System.Single)LuaCallback.ToNumber(L, 3);
            System.Single         arg3 = (System.Single)LuaCallback.ToNumber(L, 4);
            UnityEngine.Vector3   res  = arg0.InverseTransformPoint(arg1, arg2, arg3);
            LuaCallback.PushVector(L, res);
            return(1);
        }
        return(0);
    }
Beispiel #7
0
 public static void Register()
 {
     if (doNotModify)
     {
         return;
     }
     object o = null;
     {
         UnityEngine.MonoBehaviour v = (UnityEngine.MonoBehaviour)o;
         v = new UnityEngine.MonoBehaviour();
         var p1 = v.tag;
         v.tag = (System.String)o;
         var p2 = v.name;
         v.name = (System.String)o;
         v.IsInvoking();
         v.CancelInvoke();
         v.Invoke((System.String)o, (System.Single)o);
         v.InvokeRepeating((System.String)o, (System.Single)o, (System.Single)o);
         v.CancelInvoke((System.String)o);
         v.IsInvoking((System.String)o);
         v.StartCoroutine((System.String)o);
         v.StartCoroutine((System.String)o, (System.Object)o);
         v.StartCoroutine((System.Collections.IEnumerator)o);
         v.StopCoroutine((System.Collections.IEnumerator)o);
         v.StopCoroutine((UnityEngine.Coroutine)o);
         UnityEngine.MonoBehaviour.print((System.Object)o);
         v.GetComponent((System.Type)o);
         UnityEngine.Component p3 = (UnityEngine.Component)o;
         v.TryGetComponent((System.Type)o, out p3);
         v.GetComponentInChildren((System.Type)o, (System.Boolean)o);
         v.GetComponentInChildren((System.Type)o);
         v.GetComponentsInChildren((System.Type)o, (System.Boolean)o);
         v.GetComponentsInChildren((System.Type)o);
         v.GetComponentInParent((System.Type)o);
         v.GetComponentsInParent((System.Type)o, (System.Boolean)o);
         v.GetComponentsInParent((System.Type)o);
         v.GetComponents((System.Type)o);
         v.GetComponents((System.Type)o, (System.Collections.Generic.List <UnityEngine.Component>)o);
         v.CompareTag((System.String)o);
         v.SendMessageUpwards((System.String)o, (System.Object)o);
         v.SendMessageUpwards((System.String)o);
         v.SendMessageUpwards((System.String)o, (UnityEngine.SendMessageOptions)o);
         v.SendMessage((System.String)o, (System.Object)o);
         v.SendMessage((System.String)o);
         v.SendMessage((System.String)o, (UnityEngine.SendMessageOptions)o);
         v.BroadcastMessage((System.String)o, (System.Object)o);
         v.BroadcastMessage((System.String)o);
         v.BroadcastMessage((System.String)o, (UnityEngine.SendMessageOptions)o);
         v.GetInstanceID();
         v.GetHashCode();
         v.Equals((System.Object)o);
         v.ToString();
     }
     {
         UnityEngine.Transform v = (UnityEngine.Transform)o;
         var p4 = v.position;
         v.position = (UnityEngine.Vector3)o;
         var p5 = v.localPosition;
         v.localPosition = (UnityEngine.Vector3)o;
         var p6 = v.eulerAngles;
         v.eulerAngles = (UnityEngine.Vector3)o;
         var p7 = v.localEulerAngles;
         v.localEulerAngles = (UnityEngine.Vector3)o;
         var p8 = v.right;
         v.right = (UnityEngine.Vector3)o;
         var p9 = v.up;
         v.up = (UnityEngine.Vector3)o;
         var pA = v.forward;
         v.forward = (UnityEngine.Vector3)o;
         var pB = v.rotation;
         v.rotation = (UnityEngine.Quaternion)o;
         var pC = v.localRotation;
         v.localRotation = (UnityEngine.Quaternion)o;
         var pD = v.localScale;
         v.localScale = (UnityEngine.Vector3)o;
         var pE = v.parent;
         v.parent = (UnityEngine.Transform)o;
         var pF  = v.worldToLocalMatrix;
         var p10 = v.localToWorldMatrix;
         var p11 = v.root;
         var p12 = v.lossyScale;
         var p13 = v.hierarchyCapacity;
         v.hierarchyCapacity = (System.Int32)o;
         var p14 = v.hierarchyCount;
         var p15 = v.tag;
         v.tag = (System.String)o;
         var p16 = v.name;
         v.name = (System.String)o;
         v.SetParent((UnityEngine.Transform)o);
         v.SetPositionAndRotation((UnityEngine.Vector3)o, (UnityEngine.Quaternion)o);
         v.Translate((UnityEngine.Vector3)o, (UnityEngine.Space)o);
         v.Translate((UnityEngine.Vector3)o);
         v.Translate((System.Single)o, (System.Single)o, (System.Single)o, (UnityEngine.Space)o);
         v.Translate((System.Single)o, (System.Single)o, (System.Single)o);
         v.Translate((UnityEngine.Vector3)o, (UnityEngine.Transform)o);
         v.Translate((System.Single)o, (System.Single)o, (System.Single)o, (UnityEngine.Transform)o);
         v.Rotate((UnityEngine.Vector3)o, (UnityEngine.Space)o);
         v.Rotate((UnityEngine.Vector3)o);
         v.Rotate((System.Single)o, (System.Single)o, (System.Single)o, (UnityEngine.Space)o);
         v.Rotate((System.Single)o, (System.Single)o, (System.Single)o);
         v.Rotate((UnityEngine.Vector3)o, (System.Single)o, (UnityEngine.Space)o);
         v.Rotate((UnityEngine.Vector3)o, (System.Single)o);
         v.RotateAround((UnityEngine.Vector3)o, (UnityEngine.Vector3)o, (System.Single)o);
         v.LookAt((UnityEngine.Transform)o, (UnityEngine.Vector3)o);
         v.LookAt((UnityEngine.Transform)o);
         v.LookAt((UnityEngine.Vector3)o, (UnityEngine.Vector3)o);
         v.LookAt((UnityEngine.Vector3)o);
         v.TransformDirection((UnityEngine.Vector3)o);
         v.TransformDirection((System.Single)o, (System.Single)o, (System.Single)o);
         v.InverseTransformDirection((UnityEngine.Vector3)o);
         v.InverseTransformDirection((System.Single)o, (System.Single)o, (System.Single)o);
         v.TransformVector((UnityEngine.Vector3)o);
         v.TransformVector((System.Single)o, (System.Single)o, (System.Single)o);
         v.InverseTransformVector((UnityEngine.Vector3)o);
         v.InverseTransformVector((System.Single)o, (System.Single)o, (System.Single)o);
         v.TransformPoint((UnityEngine.Vector3)o);
         v.TransformPoint((System.Single)o, (System.Single)o, (System.Single)o);
         v.InverseTransformPoint((UnityEngine.Vector3)o);
         v.InverseTransformPoint((System.Single)o, (System.Single)o, (System.Single)o);
         v.Find((System.String)o);
         v.GetEnumerator();
         v.GetComponent((System.Type)o);
         UnityEngine.Component p17 = (UnityEngine.Component)o;
         v.TryGetComponent((System.Type)o, out p17);
         v.GetComponentInChildren((System.Type)o, (System.Boolean)o);
         v.GetComponentInChildren((System.Type)o);
         v.GetComponentsInChildren((System.Type)o, (System.Boolean)o);
         v.GetComponentsInChildren((System.Type)o);
         v.GetComponentInParent((System.Type)o);
         v.GetComponentsInParent((System.Type)o, (System.Boolean)o);
         v.GetComponentsInParent((System.Type)o);
         v.GetComponents((System.Type)o);
         v.GetComponents((System.Type)o, (System.Collections.Generic.List <UnityEngine.Component>)o);
         v.CompareTag((System.String)o);
         v.SendMessageUpwards((System.String)o, (System.Object)o);
         v.SendMessageUpwards((System.String)o);
         v.SendMessageUpwards((System.String)o, (UnityEngine.SendMessageOptions)o);
         v.SendMessage((System.String)o, (System.Object)o);
         v.SendMessage((System.String)o);
         v.SendMessage((System.String)o, (UnityEngine.SendMessageOptions)o);
         v.BroadcastMessage((System.String)o, (System.Object)o);
         v.BroadcastMessage((System.String)o);
         v.BroadcastMessage((System.String)o, (UnityEngine.SendMessageOptions)o);
         v.GetInstanceID();
         v.GetHashCode();
         v.Equals((System.Object)o);
         v.ToString();
     }
 }