コード例 #1
0
ファイル: Renderable.cs プロジェクト: yanshuyu/BansheeEngine
        /// <inheritdoc/>
        protected internal override bool CalculateBounds(out AABox box, out Sphere sphere)
        {
            Bounds bounds = Bounds;

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

            return(true);
        }
コード例 #2
0
        /// <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);
        }
コード例 #3
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;
        }
コード例 #4
0
        /// <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);
        }
コード例 #5
0
        /// <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;
                    bounds.TransformAffine(SceneObject.WorldTransform);

                    _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;
                }
            }
        }
コード例 #6
0
ファイル: Physics.cs プロジェクト: Ruu/BansheeEngine
 private static extern bool Internal_BoxCastAny(ref AABox box, ref Quaternion rotation, ref Vector3 unitDir, ulong layer, float max);
コード例 #7
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);
コード例 #8
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);
 }
コード例 #9
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));
 }
コード例 #10
0
ファイル: Bounds.cs プロジェクト: yura0909/BansheeEngine
 /// <summary>
 /// Creates new bounds.
 /// </summary>
 /// <param name="box">Axis aligned box representation of the bounds.</param>
 /// <param name="sphere">Sphere representation of the bounds.</param>
 public Bounds(AABox box, Sphere sphere)
 {
     Box    = box;
     Sphere = sphere;
 }
コード例 #11
0
 private static extern void Internal_getGridVolume(IntPtr thisPtr, out AABox __output);
コード例 #12
0
ファイル: EditorUtility.cs プロジェクト: Ruu/BansheeEngine
 private static extern void Internal_CalculateBoundsArray(SceneObject[] objects, out AABox bounds);
コード例 #13
0
 private static extern int Internal_AddPhysicsRegion(ref AABox region);
コード例 #14
0
 /// <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));
 }
コード例 #15
0
 /// <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));
 }
コード例 #16
0
 /// <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)));
 }
コード例 #17
0
 /// <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));
 }
コード例 #18
0
 /// <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)));
 }
コード例 #19
0
ファイル: Physics.cs プロジェクト: Ruu/BansheeEngine
 private static extern bool Internal_BoxOverlapAny(ref AABox box, ref Quaternion rotation, ulong layer);
コード例 #20
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));
 }
コード例 #21
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;
        }
コード例 #22
0
        /// <summary>
        /// Resizes the light probe grid and inserts new light probes, if the new size is larger than previous size. New probes
        /// are inserted in a grid pattern matching the new size and density parameters.
        ///
        /// Note that shrinking the volume will not remove light probes. In order to remove probes outside of the new volume call
        /// clip().
        ///
        /// Resize will not change the positions of current light probes. If you wish to reset all probes to the currently set
        /// grid position, call reset().
        /// </summary>
        /// <param name="volume">Axis aligned volume to be covered by the light probes.</param>
        public void Resize(AABox volume)
        {
            Vector3I cellCount = new Vector3I(1, 1, 1);

            Internal_resize(mCachedPtr, ref volume, ref cellCount);
        }
コード例 #23
0
 private static extern void Internal_GetBounds(IntPtr thisPtr, IntPtr parentSO, out AABox box, out Sphere sphere);
コード例 #24
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;
        }
コード例 #25
0
 private static extern void Internal_getBounds(IntPtr thisPtr, out AABox __output);
コード例 #26
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);
        }
コード例 #27
0
 private static extern void Internal_setcustomBounds(IntPtr thisPtr, ref AABox value);
コード例 #28
0
 private static extern void Internal_setBounds(IntPtr thisPtr, ref AABox bounds);
コード例 #29
0
 /// <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 = 18446744073709551615)
 {
     return(Internal_boxOverlap(ref box, ref rotation, layer));
 }
コード例 #30
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);
 }
コード例 #31
0
 /// <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 = 18446744073709551615)
 {
     return(Internal_boxOverlapAny(ref box, ref rotation, layer));
 }
コード例 #32
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);
 }
コード例 #33
0
 /// <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>
 public static uint AddPhysicsRegion(AABox region)
 {
     return(Internal_addBroadPhaseRegion(ref region));
 }
コード例 #34
0
ファイル: Physics.cs プロジェクト: Ruu/BansheeEngine
 private static extern int Internal_AddPhysicsRegion(ref AABox region);
コード例 #35
0
 private static extern bool Internal_boxCast(ref AABox box, ref Quaternion rotation, ref Vector3 unitDir, out PhysicsQueryHit hit, ulong layer, float max);
コード例 #36
0
ファイル: Physics.cs プロジェクト: Ruu/BansheeEngine
 private static extern ScriptPhysicsQueryHit[] Internal_BoxCastAll(ref AABox box, ref Quaternion rotation, ref Vector3 unitDir, ulong layer, float max);
コード例 #37
0
 private static extern PhysicsQueryHit[] Internal_boxCastAll(ref AABox box, ref Quaternion rotation, ref Vector3 unitDir, ulong layer, float max);
コード例 #38
0
ファイル: Physics.cs プロジェクト: Ruu/BansheeEngine
 private static extern NativeCollider[] Internal_BoxOverlap(ref AABox box, ref Quaternion rotation, ulong layer);
コード例 #39
0
 private static extern bool Internal_boxCastAny(ref AABox box, ref Quaternion rotation, ref Vector3 unitDir, ulong layer, float max);
コード例 #40
0
 private static extern Collider[] Internal_boxOverlap(ref AABox box, ref Quaternion rotation, ulong layer);
コード例 #41
0
 private static extern bool Internal_boxOverlapAny(ref AABox box, ref Quaternion rotation, ulong layer);
コード例 #42
0
ファイル: EditorUtility.cs プロジェクト: Ruu/BansheeEngine
 private static extern void Internal_CalculateBounds(SceneObject so, out AABox bounds);
コード例 #43
0
 private static extern uint Internal_addBroadPhaseRegion(ref AABox region);
コード例 #44
0
 /// <summary>
 /// Resizes the light probe grid and inserts new light probes, if the new size is larger than previous size. New probes
 /// are inserted in a grid pattern matching the new size and density parameters.
 ///
 /// Note that shrinking the volume will not remove light probes. In order to remove probes outside of the new volume call
 /// clip().
 ///
 /// Resize will not change the positions of current light probes. If you wish to reset all probes to the currently set
 /// grid position, call reset().
 /// </summary>
 /// <param name="volume">Axis aligned volume to be covered by the light probes.</param>
 /// <param name="cellCount">
 /// Number of grid cells to split the volume into. Minimum number of 1, in which case each corner of the volume is
 /// represented by a single probe. Higher values subdivide the volume in an uniform way.
 /// </param>
 public void Resize(AABox volume, Vector3I cellCount)
 {
     Internal_resize(mCachedPtr, ref volume, ref cellCount);
 }
コード例 #45
0
 /// <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 = 18446744073709551615, float max = 3.40282347E+38f)
 {
     return(Internal_boxCast(ref box, ref rotation, ref unitDir, out hit, layer, max));
 }
コード例 #46
0
 private static extern void Internal_resize(IntPtr thisPtr, ref AABox volume, ref Vector3I cellCount);
コード例 #47
0
ファイル: NativeRenderable.cs プロジェクト: Ruu/BansheeEngine
 private static extern void Internal_GetBounds(IntPtr thisPtr, IntPtr parentSO, out AABox box, out Sphere sphere);
コード例 #48
0
 private static extern void Internal_getBounds(IntPtr thisPtr, out AABox box, out Sphere sphere);
コード例 #49
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;
                }
            }
        }