Esempio n. 1
0
        public SSObject Intersect(ref SSRay worldSpaceRay)
        {
            SSObject nearestIntersection = null;
            float    nearestDistance     = float.MinValue;

            // distances get "smaller" as they move in camera direction for some reason (why?)
            foreach (var obj in objects)
            {
                float distanceAlongRay;
                if (obj.Selectable && obj.Intersect(ref worldSpaceRay, out distanceAlongRay))
                {
                    // intersection must be in front of the camera ( < 0.0 )
                    if (distanceAlongRay < 0.0)
                    {
                        Console.WriteLine("intersect: [{0}] @distance: {1}", obj.Name, distanceAlongRay);
                        // then we want the nearest one (numerically biggest
                        if (distanceAlongRay > nearestDistance)
                        {
                            nearestDistance     = distanceAlongRay;
                            nearestIntersection = obj;
                        }
                    }
                }
            }

            return(nearestIntersection);
        }
Esempio n. 2
0
        public SSObject Intersect(ref SSRay worldSpaceRay, out float nearestDistance)
        {
            SSObject nearestIntersection = null;

            nearestDistance = float.PositiveInfinity;
            // distances get "smaller" as they move in camera direction for some reason (why?)
            foreach (var obj in objects)
            {
                float    distanceAlongRay;
                DateTime start = DateTime.Now;
                if (obj.selectable && obj.Intersect(ref worldSpaceRay, out distanceAlongRay))
                {
                    // intersection must be in front of the camera ( < 0.0 )
                    if (distanceAlongRay > 0.0)
                    {
                        Console.WriteLine("intersect: [{0}] @distance: {1}  in {2}ms", obj.Name, distanceAlongRay, (DateTime.Now - start).TotalMilliseconds);
                        // then we want the nearest one (numerically biggest
                        if (distanceAlongRay < nearestDistance)
                        {
                            nearestDistance     = distanceAlongRay;
                            nearestIntersection = obj;
                        }
                    }
                }
            }
            return(nearestIntersection);
        }
Esempio n. 3
0
 public void AddObject(SSObject obj)
 {
     if (objects.Contains(obj))
     {
         throw new Exception("scene already contains object: " + obj);
     }
     objects.Add(obj);
 }
        protected virtual void mouseDownHandler(object sender, MouseButtonEventArgs e)
        {
            if (!base.Focused) return;

            this.mouseButtonDown = true;

            // cast ray for mouse click
            var clientRect = new System.Drawing.Size(ClientRectangle.Width, ClientRectangle.Height);
            Vector2 mouseLoc = new Vector2(e.X,e.Y);

            SSRay ray = OpenTKHelper.MouseToWorldRay(
                this.scene.renderConfig.projectionMatrix, this.scene.renderConfig.invCameraViewMatrix, clientRect, mouseLoc);

            // Console.WriteLine("mouse ({0},{1}) unproject to ray ({2})",e.X,e.Y,ray);
            // scene.addObject(new SSObjectRay(ray));

            selectedObject = scene.Intersect(ref ray);
            updateWireframeDisplayText ();
        }
Esempio n. 5
0
 public void RemoveObject(SSObject obj)
 {
     // todo threading
     objects.Remove(obj);
 }
Esempio n. 6
0
 public void AddObject(SSObject obj)
 {
     objects.Add(obj);
 }
Esempio n. 7
0
 public SSCameraThirdPerson(SSObject followTarget)
     : base()
 {
     this.FollowTarget = followTarget;
 }
        protected Vector3 _neutralViewYLocal; // "Y"

        #endregion Fields

        #region Constructors

        public SSSimpleObjectTrackingJoint(SSObjectMesh hostObject, SSObject target = null)
        {
            _hostObject = hostObject;
            targetObject = target;
        }
Esempio n. 9
0
 public void RemoveObject(SSObject obj)
 {
     // todo threading
     objects.Remove(obj);
 }
Esempio n. 10
0
 public SSCameraThirdPerson(SSObject followTarget) : base()
 {
     this.FollowTarget = followTarget;
 }
Esempio n. 11
0
 public void AddObject(SSObject obj)
 {
     if (objects.Contains(obj)) {
         throw new Exception ("scene already contains object: " + obj);
     }
     objects.Add(obj);
 }
Esempio n. 12
0
 public void AddObject(SSObject obj)
 {
     objects.Add(obj);
 }
 public SSSimpleObjectTrackingJoint(SSObjectMesh hostObject, SSObject target = null)
 {
     _hostObject  = hostObject;
     targetObject = target;
 }
Esempio n. 14
0
 protected string _showDistanceFunc(SSObject target)
 {
     var launcherObj = getLauncherObject();
     var targetPos = target != null ? target.Pos : launcherObj.Pos;
     return "dist:" + Math.Floor((launcherObj.Pos - targetPos).LengthFast).ToString();
 }