Beispiel #1
0
        /// <summary>
        /// Add an object to the group, the camera used for this group will be used for this object
        /// </summary>
        /// <param name="sceneObject">An object3D</param>
        public virtual bool Add(YnEntity3D sceneObject)
        {
            if (sceneObject is YnScene3D)
            {
                throw new Exception("[YnGroup3D] You can't add a scene on a group, use an YnGroup3D instead");
            }

            if (sceneObject == this)
            {
                throw new Exception("[YnGroup3D] You can't add this group");
            }

            sceneObject.Parent = this;

            if (_assetLoaded)
            {
                sceneObject.LoadContent();
            }

            if (_initialized)
            {
                sceneObject.Initialize();
            }

            return(_members.Add(sceneObject));
        }
Beispiel #2
0
        /// <summary>
        /// Get the distance between the mouse cursor and an object3D
        /// </summary>
        /// <param name="camera">Camera to use</param>
        /// <param name="object3D">Object3D</param>
        /// <returns>The distance between the object and the mouse cursor, -1 if not collide</returns>
        public static float MouseCollideWithObject(BaseCamera camera, YnEntity3D object3D)
        {
            float? distance = null;

            if (object3D.Dynamic)
                object3D.UpdateBoundingVolumes();

            distance = GetMouseRay(camera).Intersects(object3D.BoundingBox);

            return distance != null ? (float)distance : -1.0f;
        }
Beispiel #3
0
        /// <summary>
        /// Get the distance between the mouse cursor and an object3D
        /// </summary>
        /// <param name="camera">Camera to use</param>
        /// <param name="object3D">Object3D</param>
        /// <returns>The distance between the object and the mouse cursor, -1 if not collide</returns>
        public static float MouseCollideWithObject(BaseCamera camera, YnEntity3D object3D)
        {
            float?distance = null;

            if (object3D.Dynamic)
            {
                object3D.UpdateBoundingVolumes();
            }

            distance = GetMouseRay(camera).Intersects(object3D.BoundingBox);

            return(distance != null ? (float)distance : -1.0f);
        }
Beispiel #4
0
 /// <summary>
 /// Remove an object of the group
 /// </summary>
 /// <param name="sceneObject"></param>
 public virtual bool Remove(YnEntity3D sceneObject)
 {
     return(_members.Remove(sceneObject));
 }
Beispiel #5
0
 public YnGroup3D(YnEntity3D parent)
 {
     _members     = new YnEntity3DList();
     _initialized = false;
     _parent      = parent;
 }
Beispiel #6
0
 /// <summary>
 /// Remove an object3D of the scene
 /// </summary>
 /// <param name="object3D">Object3D to remove.</param>
 public bool Remove(YnEntity3D object3D)
 {
     return _scene.Remove(object3D);
 }
Beispiel #7
0
 /// <summary>
 /// Add an object3D on the scene
 /// </summary>
 /// <param name="object3D">An object3D</param>
 public bool Add(YnEntity3D object3D)
 {
     return _scene.Add(object3D);
 }
Beispiel #8
0
 /// <summary>
 /// Remove an object of the group
 /// </summary>
 /// <param name="sceneObject"></param>
 public virtual bool Remove(YnEntity3D sceneObject)
 {
     return _members.Remove(sceneObject);
 }
Beispiel #9
0
        /// <summary>
        /// Add an object to the group, the camera used for this group will be used for this object
        /// </summary>
        /// <param name="sceneObject">An object3D</param>
        public virtual bool Add(YnEntity3D sceneObject)
        {
            if (sceneObject is YnScene3D)
                throw new Exception("[YnGroup3D] You can't add a scene on a group, use an YnGroup3D instead");

            if (sceneObject == this)
                throw new Exception("[YnGroup3D] You can't add this group");

            sceneObject.Parent = this;

            if (_assetLoaded)
                sceneObject.LoadContent();

            if (_initialized)
                sceneObject.Initialize();

            return _members.Add(sceneObject);
        }
Beispiel #10
0
 public YnGroup3D(YnEntity3D parent)
 {
     _members = new YnEntity3DList();
     _initialized = false;
     _parent = parent;
 }
Beispiel #11
0
 /// <summary>
 /// Remove an object3D of the scene
 /// </summary>
 /// <param name="object3D">Object3D to remove.</param>
 public bool Remove(YnEntity3D object3D)
 {
     return(_scene.Remove(object3D));
 }
Beispiel #12
0
 /// <summary>
 /// Add an object3D on the scene
 /// </summary>
 /// <param name="object3D">An object3D</param>
 public bool Add(YnEntity3D object3D)
 {
     return(_scene.Add(object3D));
 }