コード例 #1
0
ファイル: Physics.cs プロジェクト: Ruu/BansheeEngine
        /// <summary>
        /// Performs a sweep into the scene using a box and returns the closest found hit, if any.
        /// </summary>
        /// <param name="box">Box to sweep through the scene.</param>
        /// <param name="rotation">Orientation of the box.</param>
        /// <param name="unitDir">Unit direction towards which to perform the sweep.</param>
        /// <param name="hit">Information recorded about a hit. Only valid if method returns true.</param>
        /// <param name="layer">Layers to consider for the query. This allows you to ignore certain groups of objects.
        ///                     </param>
        /// <param name="max">Maximum distance at which to perform the query. Hits past this distance will not be detected.
        ///                   </param>
        /// <returns>True if something was hit, false otherwise.</returns>
        public static bool BoxCast(AABox box, Quaternion rotation, Vector3 unitDir, out PhysicsQueryHit hit,
            ulong layer = ulong.MaxValue, float max = float.MaxValue)
        {
            ScriptPhysicsQueryHit scriptHit = new ScriptPhysicsQueryHit();
            if(Internal_BoxCast(ref box, ref rotation, ref unitDir, out scriptHit, layer, max))
            {
                ConvertPhysicsQueryHit(ref scriptHit, out hit);
                return true;
            }

            hit = new PhysicsQueryHit();
            return false;
        }
コード例 #2
0
ファイル: Physics.cs プロジェクト: Ruu/BansheeEngine
 private static extern bool Internal_BoxOverlapAny(ref AABox box, ref Quaternion rotation, ulong layer);
コード例 #3
0
ファイル: Physics.cs プロジェクト: Ruu/BansheeEngine
 private static extern NativeCollider[] Internal_BoxOverlap(ref AABox box, ref Quaternion rotation, ulong layer);
コード例 #4
0
ファイル: Physics.cs プロジェクト: Ruu/BansheeEngine
 private static extern bool Internal_BoxCastAny(ref AABox box, ref Quaternion rotation, ref Vector3 unitDir, ulong layer, float max);
コード例 #5
0
ファイル: Physics.cs プロジェクト: Ruu/BansheeEngine
 private static extern ScriptPhysicsQueryHit[] Internal_BoxCastAll(ref AABox box, ref Quaternion rotation, ref Vector3 unitDir, ulong layer, float max);
コード例 #6
0
ファイル: Physics.cs プロジェクト: Ruu/BansheeEngine
 private static extern bool Internal_BoxCast(ref AABox box, ref Quaternion rotation, ref Vector3 unitDir, out ScriptPhysicsQueryHit hit, ulong layer, float max);
コード例 #7
0
ファイル: Renderable.cs プロジェクト: Ruu/BansheeEngine
        /// <inheritdoc/>
        protected internal override bool CalculateBounds(out AABox box, out Sphere sphere)
        {
            Bounds bounds = Bounds;

            box = bounds.Box;
            sphere = bounds.Sphere;

            return true;
        }
コード例 #8
0
ファイル: EditorUtility.cs プロジェクト: Ruu/BansheeEngine
 private static extern void Internal_CalculateBounds(SceneObject so, out AABox bounds);
コード例 #9
0
ファイル: Physics.cs プロジェクト: Ruu/BansheeEngine
 /// <summary>
 /// Checks if the provided box overlaps any other collider in the scene.
 /// </summary>
 /// <param name="box">Box to check for overlap.</param>
 /// <param name="rotation">Orientation of the box.</param>
 /// <param name="layer">Layers to consider for the query. This allows you to ignore certain groups of objects.
 ///                     </param>
 /// <returns>True if there is overlap with another object, false otherwise.</returns>
 public static bool BoxOverlapAny(AABox box, Quaternion rotation, ulong layer = ulong.MaxValue)
 {
     return Internal_BoxOverlapAny(ref box, ref rotation, layer);
 }
コード例 #10
0
ファイル: Physics.cs プロジェクト: Ruu/BansheeEngine
 /// <summary>
 /// Returns a list of all colliders in the scene that overlap the provided box.
 /// </summary>
 /// <param name="box">Box to check for overlap.</param>
 /// <param name="rotation">Orientation of the box.</param>
 /// <param name="layer">Layers to consider for the query. This allows you to ignore certain groups of objects.
 ///                     </param>
 /// <returns>List of all colliders that overlap the box.</returns>
 public static Collider[] BoxOverlap(AABox box, Quaternion rotation, ulong layer = ulong.MaxValue)
 {
     return ConvertColliders(Internal_BoxOverlap(ref box, ref rotation, layer));
 }
コード例 #11
0
ファイル: Physics.cs プロジェクト: Ruu/BansheeEngine
 /// <summary>
 /// Performs a sweep into the scene using a box and checks if it has hit anything. This can be significantly more 
 /// efficient than other types of cast* calls.
 /// </summary>
 /// <param name="box">Box to sweep through the scene.</param>
 /// <param name="rotation">Orientation of the box.</param>
 /// <param name="unitDir">Unit direction towards which to perform the sweep.</param>
 /// <param name="layer">Layers to consider for the query. This allows you to ignore certain groups of objects.
 ///                     </param>
 /// <param name="max">Maximum distance at which to perform the query. Hits past this distance will not be detected.
 ///                   </param>
 /// <returns>True if something was hit, false otherwise.</returns>
 public static bool BoxCastAny(AABox box, Quaternion rotation, Vector3 unitDir, ulong layer = ulong.MaxValue, 
     float max = float.MaxValue)
 {
     return Internal_BoxCastAny(ref box, ref rotation, ref unitDir, layer, max);
 }
コード例 #12
0
ファイル: SceneCamera.cs プロジェクト: Ruu/BansheeEngine
        /// <summary>
        /// Moves and orients a camera so that the provided bounds end covering the camera's viewport.
        /// </summary>
        /// <param name="bounds">Bounds to frame in camera's view.</param>
        /// <param name="padding">Amount of padding to leave on the borders of the viewport, in percent [0, 1].</param>
        private void FrameBounds(AABox bounds, float padding = 0.0f)
        {
            // TODO - Use AABox bounds directly instead of a sphere to be more accurate
            float worldWidth = bounds.Size.Length;
            float worldHeight = worldWidth;

            if (worldWidth == 0.0f)
                worldWidth = 1.0f;

            if (worldHeight == 0.0f)
                worldHeight = 1.0f;

            float boundsAspect = worldWidth / worldHeight;
            float paddingScale = MathEx.Clamp01(padding) + 1.0f;
            float frustumWidth;

            // If camera has wider aspect than bounds then height will be the limiting dimension
            if (camera.AspectRatio > boundsAspect)
                frustumWidth = worldHeight * camera.AspectRatio * paddingScale;
            else // Otherwise width
                frustumWidth = worldWidth * paddingScale;

            float distance = CalcDistanceForFrustumWidth(frustumWidth);

            Vector3 forward = bounds.Center - SceneObject.Position;
            forward.Normalize();

            CameraState state = new CameraState();
            state.Position = bounds.Center - forward * distance;
            state.Rotation = Quaternion.LookRotation(forward, Vector3.YAxis);
            state.Ortographic = camera.ProjectionType == ProjectionType.Orthographic;
            state.FrustumWidth = frustumWidth;

            SetState(state);
        }
コード例 #13
0
ファイル: Component.cs プロジェクト: Ruu/BansheeEngine
        /// <summary>
        /// Calculates bounds of the visible content for this component.
        /// </summary>
        /// <param name="box">Bounds in world space represented as an axis aligned bounding box.</param>
        /// <param name="sphere">Bounds in world space represented as a sphere.</param>
        /// <returns>True if the bounds have non-zero volume, false otherwise.</returns>
        protected internal virtual bool CalculateBounds(out AABox box, out Sphere sphere)
        {
            Vector3 pos = SceneObject.Position;

            box = new AABox(pos, pos);
            sphere = new Sphere(pos, 0.0f);

            return false;
        }
コード例 #14
0
ファイル: NativeRenderable.cs プロジェクト: Ruu/BansheeEngine
 private static extern void Internal_GetBounds(IntPtr thisPtr, IntPtr parentSO, out AABox box, out Sphere sphere);
コード例 #15
0
ファイル: Physics.cs プロジェクト: Ruu/BansheeEngine
 /// <summary>
 /// Adds a new physics region. Certain physics options require you to set up regions in which physics objects are
 /// allowed to be in, and objects outside of these regions will not be handled by physics.You do not need to set
 /// up these regions by default.
 /// </summary>
 /// <param name="region">Region of space that physics objects are allowed to be in.</param>
 /// <returns>A unique handle to the region.</returns>
 public static int AddPhysicsRegion(AABox region)
 {
     return Internal_AddPhysicsRegion(ref region);
 }
コード例 #16
0
ファイル: Physics.cs プロジェクト: Ruu/BansheeEngine
 /// <summary>
 /// Performs a sweep into the scene using a box and returns all found hits.
 /// </summary>
 /// <param name="box">Box to sweep through the scene.</param>
 /// <param name="rotation">Orientation of the box.</param>
 /// <param name="unitDir">Unit direction towards which to perform the sweep.</param>
 /// <param name="layer">Layers to consider for the query. This allows you to ignore certain groups of objects.
 ///                     </param>
 /// <param name="max">Maximum distance at which to perform the query. Hits past this distance will not be detected.
 ///                   </param>
 /// <returns>List of all detected hits.</returns>
 public static PhysicsQueryHit[] BoxCastAll(AABox box, Quaternion rotation,
     Vector3 unitDir, ulong layer = ulong.MaxValue, float max = float.MaxValue)
 {
     return ConvertPhysicsQueryHits(Internal_BoxCastAll(ref box, ref rotation, ref unitDir, layer, max));
 }
コード例 #17
0
ファイル: Physics.cs プロジェクト: Ruu/BansheeEngine
 private static extern int Internal_AddPhysicsRegion(ref AABox region);
コード例 #18
0
ファイル: EditorUtility.cs プロジェクト: Ruu/BansheeEngine
 private static extern void Internal_CalculateBoundsArray(SceneObject[] objects, out AABox bounds);
コード例 #19
0
ファイル: Animation.cs プロジェクト: BearishSun/BansheeEngine
        /// <summary>
        /// Re-applies the bounds to the internal animation object, and the relevant renderable object if one exists.
        /// </summary>
        internal void UpdateBounds(bool updateRenderable = true)
        {
            NativeRenderable renderable = null;
            if (updateRenderable && animatedRenderable != null)
                renderable = animatedRenderable.Native;

            if (serializableData.useBounds)
            {
                if (renderable != null)
                {
                    renderable.UseOverrideBounds = true;
                    renderable.OverrideBounds = serializableData.bounds;
                }

                if (_native != null)
                {
                    AABox bounds = serializableData.bounds;

                    Matrix4 parentTfrm;
                    if (SceneObject.Parent != null)
                        parentTfrm = SceneObject.Parent.WorldTransform;
                    else
                        parentTfrm = Matrix4.Identity;

                    bounds.TransformAffine(parentTfrm);

                    _native.Bounds = bounds;
                }
            }
            else
            {
                if (renderable != null)
                    renderable.UseOverrideBounds = false;

                if (_native != null)
                {
                    AABox bounds = new AABox();
                    if (animatedRenderable != null)
                        bounds = animatedRenderable.Bounds.Box;

                    _native.Bounds = bounds;
                }
            }
        }