Пример #1
0
        public void UpdateView(bool update3D)
        {
            if (update3D)
            {
                Render3dSpace = true;
            }
            glControl1.Invalidate();
            if (UVDLPApp.Instance().SelectedObject != null)
            {
                if (UVDLPApp.Instance().SelectedObject.tag == Object3d.OBJ_SUPPORT)
                {
                    Support sup = (Support)UVDLPApp.Instance().SelectedObject;

                    RTUtils.UpdateObjectSelectionPlane(sup.Centroid(), m_camera.m_right, m_camera.m_up);
                }
                else
                {
                    RTUtils.UpdateObjectSelectionPlane(UVDLPApp.Instance().SelectedObject.m_center, m_camera.m_right, m_camera.m_up);
                }
            }
            //DisplayFunc();
        }
Пример #2
0
        private void glControl1_MouseMove(object sender, MouseEventArgs e)
        {
            double dx = 0, dy = 0;

            if (lmdown || rmdown || mmdown)
            {
                dx  = e.X - mdx;
                dy  = e.Y - mdy;
                mdx = e.X;
                mdy = e.Y;
            }
            dx /= 2;
            dy /= 2;

            if (lmdown)
            {
                m_camera.RotateRightFlat((float)dx);
                m_camera.RotateUp((float)dy);
                m_axisCam.RotateRightFlat((float)dx);
                m_axisCam.RotateUp((float)dy);

                UpdateView();
            }
            else if (mmdown)
            {
                m_camera.MoveForward((float)dy);
                UpdateView();
            }
            else if (rmdown)
            {
                m_camera.Move((float)dx, (float)dy);
                UpdateView();
            }

            // if no object selected, bail
            if (UVDLPApp.Instance().SelectedObject == null)
            {
                return;
            }

            if (m_movingobjectmode)                            // if we're moving an object - shift key down
            {
                List <ISectData> hits = TestHitTest(e.X, e.Y); // hit-test all
                // examine the last isect data
                foreach (ISectData dat in hits)
                {
                    //remember to break out of this foreach loop after executing a movement.

                    // either we're moving a support
                    if (UVDLPApp.Instance().SelectedObject.tag == Object3d.OBJ_SUPPORT)
                    {
                        // if it's the base we're moving,
                        //allow the base to change types
                        // see if it intersects with the ground, or an object
                        //cast as a support object
                        Support sup = (Support)UVDLPApp.Instance().SelectedObject;
                        if (sup.SelectionType == Support.eSelType.eWhole)
                        {
                            // we're in modify mode, but we're still moving the whole support
                            if (dat.obj.tag == Object3d.OBJ_SEL_PLANE)
                            {
                                //we should really try a top/ bottom intersection / scale to hieg
                                // move the support
                                sup.Translate(
                                    (float)(dat.intersect.x - UVDLPApp.Instance().SelectedObject.m_center.x),
                                    (float)(dat.intersect.y - UVDLPApp.Instance().SelectedObject.m_center.y),
                                    0.0f);
                                // now we've moved the object approximately to where it needs to be
                                //turn it back into a base
                                sup.SubType = Support.eSubType.eBase;
                                //get the center location
                                Point3d           centroid = sup.Centroid();
                                Engine3D.Vector3d upvec    = new Engine3D.Vector3d();
                                upvec.Set(0, 0, 1);
                                Point3d origin = new Point3d();
                                origin.Set(centroid.x, centroid.y, .001f);    // above the ground plane
                                List <ISectData> isects = RTUtils.IntersectObjects(upvec, origin, UVDLPApp.Instance().Engine3D.m_objects, false);
                                foreach (ISectData isd in isects)
                                {
                                    if (isd.obj.tag == Object3d.OBJ_NORMAL)    // if we've intersected a normal object upwards
                                    {
                                        sup.SelectionType = Support.eSelType.eTip;
                                        sup.MoveFromTip(isd);
                                        sup.SelectionType = Support.eSelType.eWhole;
                                        break;
                                    }
                                }
                                //starting at the x/y ground plane, hittest upward
                                break;
                            }
                        }
                        else if (sup.SelectionType == Support.eSelType.eBase)
                        {
                            //going to change this to test for intersection with object, or ground plane
                            // if intersected with an object, change to intra type
                            // and set the base on the object
                            // if intersected with ground, change to base type and put on ground
                            if (dat.obj.tag == Object3d.OBJ_GROUND)
                            {
                                // make sure we're a base tip
                                sup.SubType = Support.eSubType.eBase;
                                // position the bottom to the intersection point
                                sup.PositionBottom(dat);
                                break;
                            }
                            else if (dat.obj.tag == Object3d.OBJ_NORMAL)     // intersected with an object
                            {
                                //should check with the normal of the object to see if it's facing upwards
                                sup.SubType = Support.eSubType.eIntra;
                                // position the bottom to the intersection point
                                sup.PositionBottom(dat);
                                break;
                            }
                        }
                        else if (sup.SelectionType == Support.eSelType.eTip)
                        {
                            if (dat.obj.tag == Object3d.OBJ_NORMAL)     // intersected with an object
                            {
                                sup.MoveFromTip(dat);
                                UpdateView();
                                break;
                            }
                        }
                    }
                    else     // or a normal object based on object selection plane
                    {
                        if (dat.obj.tag == Object3d.OBJ_SEL_PLANE)
                        {
                            UVDLPApp.Instance().SelectedObject.Translate(
                                (float)(dat.intersect.x - UVDLPApp.Instance().SelectedObject.m_center.x),
                                (float)(dat.intersect.y - UVDLPApp.Instance().SelectedObject.m_center.y),
                                0.0f);
                        }
                        break;
                    }
                }
                UpdateView();
            }
        }