예제 #1
0
 private void RaiseEvent(eCSGEvent ev, string msg, Object3d dat)
 {
     if (CSGEvent != null)
     {
         CSGEvent(ev, msg, dat);
     }
 }
        /*
         * Return a list of polygons that intersect at this zlevel
         */
        public List <Polygon> GetZPolys(Object3d obj, double zlev)
        {
            List <Polygon> lst = new List <Polygon>();

            try
            {
                if (zlev >= obj.m_min.z && zlev <= obj.m_max.z)
                {
                    foreach (Polygon p in obj.m_lstpolys)
                    {
                        //check and see if current z level is between any of the polygons z coords
                        //MinMax mm = p.CalcMinMax();
                        if (p.m_minmax.InRange(zlev))
                        {
                            lst.Add(p);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                DebugLogger.Instance().LogError(ex.Message);
            }
            return(lst);
        }
예제 #3
0
        private void lblZ_Click(object sender, EventArgs e)
        {
            Object3d o = UVDLPApp.Instance().SelectedObject;

            if (o != null)
            {
                //by sypark 20160204
                ctlMirror.ScaleM = 1;
                //

                //by sypark 2016-02-25
                UVDLPApp.Instance().m_undoer.RemoveList();
                UVDLPApp.Instance().m_undoer.UpdateButtons();
                UVDLPApp.Instance().m_undoer.SaveMirror(o, 1.0f, 1.0f, -1.0f);
                //by sypark
                o.Scale(1.0f, 1.0f, -1.0f);
                o.FlipWinding();
                o.Update();

                //by sypark 20160204
                UVDLPApp.Instance().SelectedObject.MarkPolysDown(UVDLPApp.Instance().m_supportconfig.downangle);
                ctlMirror.ScaleM = 0;
                //
            }
            UVDLPApp.Instance().RaiseAppEvent(eAppEvent.eReDraw, "");
        }
예제 #4
0
        /*
         * Return a list of polygons that intersect at this zlevel
         */
        public List <Polygon> GetZPolys(Object3d obj, double zlev)
        {
            return(obj.m_lstpolys.Where(p => p.m_minmax.InRange(zlev)).ToList());

            /*
             * List<Polygon> lst = new List<Polygon>();
             * try
             * {
             *  if (zlev >= obj.m_min.z && zlev <= obj.m_max.z)
             *  {
             *
             *      return obj.m_lstpolys.Where(p => p.m_minmax.InRange(zlev)).ToList();
             *
             *      foreach (Polygon p in obj.m_lstpolys)
             *      {
             *          //check and see if current z level is between any of the polygons z coords
             *          //MinMax mm = p.CalcMinMax();
             *          if (p.m_minmax.InRange(zlev))
             *          {
             *              lst.Add(p);
             *          }
             *      }
             *  }
             * }
             * catch (Exception ex)
             * {
             *  DebugLogger.Instance().LogError(ex.Message);
             * }
             * return lst;
             */
        }
        public Bitmap GeneratePreview(int xsize, int ysize, Object3d obj)
        {
            List <Object3d> objs = new List <Object3d>();

            objs.Add(obj);
            return(GeneratePreview(xsize, ysize, objs));
        }
예제 #6
0
        private void glControl1_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.ControlKey)
            {
                ctrldown = false;
            }

            if (e.KeyCode == Keys.ShiftKey)
            {
                m_movingobjectmode = false;
                // update object info
                Object3d obj = UVDLPApp.Instance().SelectedObject;
                if (obj != null)
                {
                    m_savex = obj.m_center.x - m_savex;
                    m_savey = obj.m_center.y - m_savey;
                    //m_savez = obj.m_center.z - m_savez;
                    UVDLPApp.Instance().m_undoer.SaveTranslation(obj, m_savex, m_savey, 0);
                    if (obj.tag == Object3d.OBJ_SUPPORT)
                    {
                        //obj.CalcMinMaxes();
                        obj.FindMinMax();
                        m_saveh = (obj.m_max.z - obj.m_min.z) / m_saveh;
                        UVDLPApp.Instance().m_undoer.SaveScale(obj, 1, 1, m_saveh);
                        UVDLPApp.Instance().m_undoer.LinkToPrev();
                    }
                }
            }
        }
예제 #7
0
 private void cmdCopy_Click(object sender, EventArgs e)
 {
     //copy the object
     if (UVDLPApp.Instance().SelectedObject != null &&
         (UVDLPApp.Instance().SelectedObject.GetType() != typeof(Support)))
     {
         try
         {
             Object3d obj = UVDLPApp.Instance().SelectedObject.Copy();
             foreach (Object3d sup in obj.m_supports)
             {
                 UVDLPApp.Instance().m_engine3d.AddObject(sup);
             }
             UVDLPApp.Instance().m_engine3d.AddObject(obj);
             UVDLPApp.Instance().m_undoer.SaveAddition(obj);
             UVDLPApp.Instance().m_engine3d.RearrangeObjects();
             UVDLPApp.Instance().RaiseAppEvent(eAppEvent.eModelAdded, "ModelCreated");
             SetupSceneTree();
         }
         catch (Exception ex)
         {
             DebugLogger.Instance().LogError(ex);
         }
     }
 }
예제 #8
0
    public void DrawFunctionParma()
    {
        if (EditorTools.DrawHeader("FUNCTION PROPERTIES"))
        {
            GUILayout.Space(6f);
            Object3d           object3d       = target as Object3d;
            FunctionType       oldType        = object3d.M_Old_FunctionType;
            SerializedProperty m_FunctionType = serializedObject.FindProperty("m_FunctionType");
            EditorGUILayout.PropertyField(m_FunctionType, new GUIContent("FunctionType"), false);

            if (oldType != object3d.M_FunctionType)
            {
                object3d._ChangeFunction();
                if (object3d as Block)
                {
                    Block block = (Block)object3d;
                    for (int i = 0; i < block.M_Bricks.Count; i++)
                    {
                        EditorUtility.SetDirty(block.M_Bricks [i]);
                    }
                }
                Debug.Log("ddf");
            }
            object3d.M_Old_FunctionType = object3d.M_FunctionType;
        }
    }
 public Object3d fnCopySupport(Object3d objSup, Object3d objCopy)
 {
     if (objSup.Name.Contains("T1") == true)
     {
         Type1Support supCurr = (Type1Support)objSup;
         Type1Support supCopy = supCurr.MakeCopy1();
         UVDLPApp.Instance().m_engine3d.AddObject(supCopy);
         UVDLPApp.Instance().m_undoer.SaveAddition(supCopy);
         objCopy.AddSupport(supCopy);
         return((Object3d)supCopy);
     }
     else if (objSup.Name.Contains("T2") == true)
     {
         Type2Support supCurr = (Type2Support)objSup;
         Type2Support supCopy = supCurr.MakeCopy2();
         UVDLPApp.Instance().m_engine3d.AddObject(supCopy);
         UVDLPApp.Instance().m_undoer.SaveAddition(supCopy);
         objCopy.AddSupport(supCopy);
         return((Object3d)supCopy);
     }
     else if (objSup.Name.Contains("_Base") == true)
     {
         SupportBase supCurr = (SupportBase)objSup;
         SupportBase supCopy = supCurr.MakeCopyBase();
         supCopy.m_parent = objCopy;            // by esyeon 2016-03-09
         UVDLPApp.Instance().m_engine3d.AddObject(supCopy);
         UVDLPApp.Instance().m_undoer.SaveAddition(supCopy);
         objCopy.m_supports.Insert(0, supCopy);             // by esyeon 2016-03-09
         return((Object3d)supCopy);
     }
     return(null);
 }
예제 #10
0
    public void DrawMoveParma()
    {
        if (EditorTools.DrawHeader("MOVE PROPERTIES"))
        {
            Object3d object3d = target as Object3d;
            GUILayout.Space(6f);
            GUI.changed = false;
            Vector3 moveSpan     = EditorGUILayout.Vector3Field("MoveSpan", object3d.M_MoveSpan);
            int     moveDuration = EditorGUILayout.IntField("Duration", (int)object3d.M_MoveDuration);
            int     moveDelay    = EditorGUILayout.IntField("Delay", object3d.M_MoveDelay);

            SerializedProperty activeMoveCondition = serializedObject.FindProperty("m_MoveActiveConditionType");
            EditorGUILayout.PropertyField(activeMoveCondition, new GUIContent("MoveActiveCondition"), false);

            SerializedProperty activeCondition = serializedObject.FindProperty("m_ActiveConditionType");
            EditorGUILayout.PropertyField(activeCondition, new GUIContent("ActiveCondition"), false);

            int ACT_ArrvieTime = EditorGUILayout.IntField("ACT_ArrvieTime", object3d.M_ACT_ArrvieTime);

            if (GUI.changed)
            {
                object3d.M_MoveSpan       = moveSpan;
                object3d.M_MoveDuration   = moveDuration;
                object3d.M_MoveDelay      = moveDelay;
                object3d.M_ACT_ArrvieTime = ACT_ArrvieTime;
                EditorUtility.SetDirty(object3d);
            }
        }
    }
예제 #11
0
 private void glControl1_KeyDown(object sender, KeyEventArgs e)
 {
     // if the delete key is pressed, deleted the currently selected object
     if (e.KeyCode == Keys.Delete)
     {
         UVDLPApp.Instance().RemoveCurrentModel();
     }
     if ((e.KeyCode == Keys.Z) && (e.Modifiers == Keys.Control))
     {
         UVDLPApp.Instance().m_undoer.Undo();
     }
     if (e.KeyCode == Keys.ShiftKey)
     {
         if (m_movingobjectmode == false)
         {
             m_movingobjectmode = true;
             Object3d obj = UVDLPApp.Instance().SelectedObject;
             if (obj != null)
             {
                 m_savex = obj.m_center.x;
                 m_savey = obj.m_center.y;
                 //m_savez = obj.m_center.z;
                 if (obj.tag == Object3d.OBJ_SUPPORT)
                 {
                     obj.CalcMinMaxes();
                     m_saveh = obj.m_max.z - obj.m_min.z;
                 }
             }
         }
     }
 }
예제 #12
0
        private void RunThread()
        {
            RaiseEvent(eCSGEvent.eStarted, "", null);
            try
            {
                List <csgjs_polygon> a  = ConvertTo(m_obj1);
                List <csgjs_polygon> b  = ConvertTo(m_obj2);
                csgjs_csgnode        A  = new csgjs_csgnode(a);
                csgjs_csgnode        B  = new csgjs_csgnode(b);
                csgjs_csgnode        AB = null;
                switch (m_op)
                {
                case eCSGOp.eIntersection:
                    AB = csgjs_csgnode.csg_intersect(A, B);
                    break;

                case eCSGOp.eSubtraction:
                    AB = csgjs_csgnode.csg_subtract(A, B);
                    break;

                case eCSGOp.eUnion:
                    AB = csgjs_csgnode.csg_union(A, B);
                    break;
                }
                //raise an event
                Object3d res = ConvertFrom(AB.allPolygons());
                RaiseEvent(eCSGEvent.eCompleted, "", res);
            }
            catch (Exception ex)
            {
                DebugLogger.Instance().LogError(ex);
                RaiseEvent(eCSGEvent.eError, "", null);
            }
            m_running = false;
        }
예제 #13
0
        private static void CreateGroundPlane()
        {
            m_gp      = new Object3d();
            m_gp.Name = "GroundPlane";
            Point3d p0 = new Point3d(-500, -500, 0);
            Point3d p1 = new Point3d(500, -500, 0);
            Point3d p2 = new Point3d(500, 500, 0);
            Point3d p3 = new Point3d(-500, 500, 0);

            m_gp.m_lstpoints.Add(p0);
            m_gp.m_lstpoints.Add(p1);
            m_gp.m_lstpoints.Add(p2);
            m_gp.m_lstpoints.Add(p3);

            Polygon ply0 = new Polygon();

            ply0.m_points    = new Point3d[3];
            ply0.m_points[0] = p0;
            ply0.m_points[1] = p1;
            ply0.m_points[2] = p2;

            Polygon ply1 = new Polygon();

            ply1.m_points    = new Point3d[3];
            ply1.m_points[0] = p0;
            ply1.m_points[1] = p2;
            ply1.m_points[2] = p3;
            m_gp.m_lstpolys.Add(ply0);
            m_gp.m_lstpolys.Add(ply1);
            m_gp.tag = Object3d.OBJ_GROUND; // groundplane tag
            m_gp.Update();
            // p1.m
        }
        public void FillObjectInfo(Object3d obj)
        {
            if (obj == null)
            {
                foreach (Control ctl in layoutPanel.Controls)
                {
                    if (ctl.GetType() == typeof(ctlInfoItem))
                    {
                        ((ctlInfoItem)ctl).DataText = "";
                    }
                }
                tName.Text = "";
                return;
            }
            obj.FindMinMax();
            tName.Text       = obj.Name;
            tPoints.DataText = obj.NumPoints.ToString();
            tPolys.DataText  = obj.NumPolys.ToString();
            tMin.DataText    = String.Format("{0:0.00}, {1:0.00}, {2:0.00}", obj.m_min.x, obj.m_min.y, obj.m_min.z);
            tMax.DataText    = String.Format("{0:0.00}, {1:0.00}, {2:0.00}", obj.m_max.x, obj.m_max.y, obj.m_max.z);
            double xs, ys, zs;

            xs             = obj.m_max.x - obj.m_min.x;
            ys             = obj.m_max.y - obj.m_min.y;
            zs             = obj.m_max.z - obj.m_min.z;
            tSize.DataText = String.Format("{0:0.00}, {1:0.00}, {2:0.00}", xs, ys, zs);
            double vol = obj.Volume;

            vol /= 1000.0; // convert to cm^3
            tVolume.DataText = string.Format("{0:0.000} cm^3", vol);
            double cost = vol * (UVDLPApp.Instance().m_buildparms.m_resinprice / 1000.0);

            tCost.DataText = string.Format("{0:0.000}", cost);
        }
예제 #15
0
        /// <summary>
        /// For now this is the editing mode for the currently selected support
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void glControl1_Click(object sender, EventArgs e)
        {
            // single click on GL Control
            Object3d obj = UVDLPApp.Instance().SelectedObject;

            if (obj == null)
            {
                return;
            }
            if (ctrldown == false)
            {
                return;                    // ctrl need to be held down
            }
            // this object is a support
            if (obj.tag == Object3d.OBJ_SUPPORT)
            {
                Support sup = (Support)obj;// we can cast safely
                // now we have to see if we clicked on an object
                MouseEventArgs   me           = e as MouseEventArgs;
                MouseButtons     buttonPushed = me.Button;
                int              xPos         = me.X;
                int              yPos         = me.Y;
                List <ISectData> isects       = TestHitTest(xPos, yPos);
                if (isects.Count == 0)
                {
                    return;                    // no intersections
                }
                ISectData isd1 = null;
                foreach (ISectData isd in isects)
                {
                    // find the closest object we clicked
                    if (isd.obj.tag == Object3d.OBJ_NORMAL)
                    {
                        isd1 = isd; //  save it
                        break;
                    }
                }
                if (isd1 == null)
                {
                    return;               // no object intersection
                }
                isd1.poly.CalcNormal();
                m_isectnormal.x = isd1.poly.m_normal.x;
                m_isectnormal.y = isd1.poly.m_normal.y;
                m_isectnormal.z = isd1.poly.m_normal.z;
                // ok, we've got the normal, we know where we've intersected
                // my best guess is that we should move the support 5mm in the direction of the camera
                // the tip of the support should touch the intersection point
                // let's start with scaling the height...
                //sup.ScaleToHeight(isd1.intersect.z);
                //m_camera.m_eye
                Engine3D.Vector3d towardseye = new Engine3D.Vector3d();
                towardseye = m_isectnormal; // -m_camera.m_eye;
                towardseye.Normalize();     // make the unit length of 1
                towardseye.Scale(4.0f);     // scale to 5 mm
                sup.MoveFromTip(isd1.intersect, towardseye);
                UpdateView();
                //sup.
            }
        }
예제 #16
0
        private Object3d ConvertFrom(List <csgjs_polygon> lstply)
        {
            Object3d obj = new Object3d();

            for (int i = 0; i < lstply.Count; i++)
            {
                csgjs_polygon poly = lstply[i];

                for (int j = 2; j < poly.vertices.Count; j++)
                {
                    Polygon ply = new Polygon(); // create a new polygon
                    ply.m_points = new Point3d[3];
                    obj.m_lstpolys.Add(ply);     //add it to the list

                    Point3d p0 = new Point3d();
                    Point3d p1 = new Point3d();
                    Point3d p2 = new Point3d();

                    p0.Set(poly.vertices[0].pos.x, poly.vertices[0].pos.y, poly.vertices[0].pos.z);
                    p1.Set(poly.vertices[j - 1].pos.x, poly.vertices[j - 1].pos.y, poly.vertices[j - 1].pos.z);
                    p2.Set(poly.vertices[j].pos.x, poly.vertices[j].pos.y, poly.vertices[j].pos.z);

                    ply.m_points[0] = p0;
                    ply.m_points[1] = p1;
                    ply.m_points[2] = p2;

                    obj.m_lstpoints.Add(p0);
                    obj.m_lstpoints.Add(p1);
                    obj.m_lstpoints.Add(p2);
                }
            }
            obj.Update();
            return(obj);
        }
예제 #17
0
        public void CSGEvent(CSG.eCSGEvent ev, string msg, Object3d dat)
        {
            try
            {
                switch (ev)
                {
                case CSG.eCSGEvent.eCompleted:
                    m_engine3d.AddObject(dat);
                    RaiseAppEvent(eAppEvent.eReDraw, "");
                    break;

                case CSG.eCSGEvent.eError:
                    break;

                case CSG.eCSGEvent.eProgress:
                    break;

                case CSG.eCSGEvent.eStarted:
                    break;
                }
            }
            catch (Exception ex)
            {
                DebugLogger.Instance().LogError(ex);
            }
        }
예제 #18
0
    public void DrawMoveInOutParam()
    {
        Object3d object3d = target as Object3d;

        if (object3d is Brick)
        {
            return;
        }

        if (EditorTools.DrawHeader("MOVE IN OUT PROPERTIES"))
        {
            GUILayout.Space(6f);
            GUI.changed = false;



            SerializedProperty moveInCT = serializedObject.FindProperty("m_MoveIn_CT");
            EditorGUILayout.PropertyField(moveInCT, new GUIContent("moveInCT"), false);

            if (object3d.M_MoveIn_CT != MoveIn_ConditionType.EMPTY)
            {
                Vector3 moveInSpan        = EditorGUILayout.Vector3Field("MoveInSpan", object3d.M_MoveIn_Span);
                int     moveInDuration    = EditorGUILayout.IntField("MoveInDuration", object3d.M_MoveIn_Duration);
                int     moveIn_ArriveTime = EditorGUILayout.IntField("MoveIn_ArriveTime", object3d.M_MoveIn_ArriveTime);
                int     moveIn_Delay      = EditorGUILayout.IntField("MoveIn_Delay", object3d.M_MoveIn_Delay);

                if (GUI.changed)
                {
                    object3d.M_MoveIn_Span       = moveInSpan;
                    object3d.M_MoveIn_Duration   = moveInDuration;
                    object3d.M_MoveIn_ArriveTime = moveIn_ArriveTime;
                    object3d.M_MoveIn_Delay      = moveIn_Delay;
                    EditorUtility.SetDirty(object3d);
                }
            }

            GUILayout.Space(16f);
            GUI.changed = false;
            SerializedProperty moveOutCT = serializedObject.FindProperty("m_MoveOut_CT");
            EditorGUILayout.PropertyField(moveOutCT, new GUIContent("moveOutCT"), false);

            if (object3d.M_MoveOut_CT != MoveOut_ConditionType.EMPTY)
            {
                Vector3 moveOutSpan       = EditorGUILayout.Vector3Field("MoveOutSpan", object3d.M_MoveOut_Span);
                int     moveOutDuration   = EditorGUILayout.IntField("MoveOutDuration", object3d.M_MoveOut_Duration);
                int     moveOut_LeaveTime = EditorGUILayout.IntField("MoveOut_LeaveTime", object3d.M_MoveOut_LeaveTime);
                int     moveOut_Delay     = EditorGUILayout.IntField("MoveOut_Delay", object3d.M_MoveOut_Delay);

                if (GUI.changed)
                {
                    object3d.M_MoveOut_Span      = moveOutSpan;
                    object3d.M_MoveOut_Duration  = moveOutDuration;
                    object3d.M_MoveOut_LeaveTime = moveOut_LeaveTime;
                    object3d.M_MoveOut_Delay     = moveOut_Delay;
                    EditorUtility.SetDirty(object3d);
                }
            }
        }
    }
예제 #19
0
 public void CalcScene()
 {
     m_sceneobject = new Object3d();
     foreach (Object3d obj in m_engine3d.m_objects)
     {
         m_sceneobject.Add(obj);
     }
 }
        private void cmdCopy_Click(object sender, EventArgs e)
        {
            //by sypark 2016-03-10
            if (UVDLPApp.Instance().SelectedObject is Support)
            {
                return;
            }
            //by sypark

            //copy the object
            Object3d objCurr = UVDLPApp.Instance().SelectedObject;

            if (objCurr != null)
            {
                try
                {
                    if (objCurr.tag != Object3d.OBJ_NORMAL)
                    {
                        Object3d objSup = fnCopySupport((Object3d)objCurr, objCurr.m_parent);

                        if (objSup != null)
                        {
                            UVDLPApp.Instance().SelectedObject = objSup;
                        }

                        UVDLPApp.Instance().RaiseAppEvent(eAppEvent.eModelAdded, "Model Created");
                        return;
                    }

                    Object3d objCopy = UVDLPApp.Instance().SelectedObject.Copy();
                    UVDLPApp.Instance().m_engine3d.AddObject(objCopy);
                    List <Object3d> lstsupports = objCopy.m_supports;
                    UVDLPApp.Instance().m_undoer.SaveAddition(objCopy);

                    int nCount = objCurr.m_supports.Count;
                    for (int i = 0; i < nCount; i++)
                    {
                        fnCopySupport((Object3d)objCurr.m_supports[i], objCopy);
                    }

                    UVDLPApp.Instance().SelectedObject = objCopy;

                    // by esyeon 2016-02-17
                    //UVDLPApp.Instance().SelectedObject = obj;
                    // by esyeon

                    UVDLPApp.Instance().RaiseAppEvent(eAppEvent.eModelAdded, "Model Created");

                    // by esyeon 2016-02-17
                    //SetupSceneTree();
                    // by esyeon
                }
                catch (Exception ex)
                {
                    DebugLogger.Instance().LogError(ex);
                }
            }
        }
예제 #21
0
 void UpdateWorldPot(Object3d parent)
 {
     if (parent != null)
     {
         m_StartPot = m_Parent.M_StartPot + m_Loc_StartPot;
         m_EndPot   = m_Parent.M_EndPot + m_Loc_EndPot;
         UpdateWorldPot(parent.m_Parent);
     }
 }
예제 #22
0
파일: Controller.cs 프로젝트: konlil/pipe
 public virtual void Detatch()
 {
     if(controlled_entity != null)
     {
         Object3d tmp = controlled_entity;
         controlled_entity = null;
         tmp.DetatchController(this);
     }
 }
예제 #23
0
        private void btn_DrawObject_Click(object sender, EventArgs e)
        {
            ListBox listbox = ((ListBox)tabControl1.SelectedTab.GetChildAtPoint(new Point(0, 0)));

            ObjForListView model = (ObjForListView)(listbox.SelectedItem);

            if (model != null)
            {
                Vector3 scale = new Vector3(1f, 1f, 1f);
                switch (model.Name)
                {
                case "droid":
                    scale = new Vector3(0.085f, 0.085f, 0.085f);
                    break;

                case "miku":
                    scale = new Vector3(0.35f, 0.35f, 0.35f);
                    break;

                case "tournevis":
                    scale = new Vector3(7.7f, 7.7f, 7.7f);
                    break;

                case "flecheVerte":
                    scale = new Vector3(0.88f, 0.88f, 0.88f);
                    break;

                case "box":
                    scale = new Vector3(20f, 20f, 20f);
                    break;
                }
                Object3d obj3d = new Object3d(Convert.ToInt32(model.Id), model.Name, model.Type,
                                              new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0, 0, 0), scale, RenderForm.m_Device);
                obj3d.setNb(this.number);

                try
                {
                    obj3d.LoadMesh();
                }
                catch (FileNotFoundException)
                {
                    string str = "Le modèle " + obj3d.getName() + " n'existe pas dans le chemain " + obj3d.getPath();
                    MessageBox.Show(this, str, "Message d'erreur", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                RenderForm.Objects.Add(obj3d);
                lstbx_Objects.Items.Add(model);
                tabControl1.SelectedIndex = 0;
                if (lstbx_Objects.Items.Count > 0)
                {
                    lstbx_Objects.SelectedIndex = lstbx_Objects.Items.Count - 1;
                    lstbx_Objects_Click(null, EventArgs.Empty);
                }
                btn_RemoveObject.Enabled = true;
            }
        }
예제 #24
0
        public static Object3d Sphere(float radius, int rings, int sectors)
        {
            try
            {
                Object3d sp = new Object3d();
                sp.Name = "Sphere";
                float R = 1f / (float)(rings - 1);
                float S = 1f / (float)(sectors - 1);

                float M_PI   = (float)Math.PI;// *0.0174532925f; // with deg2rad
                float M_PI_2 = M_PI / 2;
                for (int r = 0; r < rings; r++)
                {
                    for (int s = 0; s < sectors; s++)
                    {
                        float y = (float)Math.Sin(-M_PI_2 + M_PI * r * R);
                        float x = (float)Math.Cos(2 * M_PI * s * S) * (float)Math.Sin(M_PI * r * R);
                        float z = (float)Math.Sin(2 * M_PI * s * S) * (float)Math.Sin(M_PI * r * R);

                        Point3d pnt = new Point3d(x * radius, y * radius, z * radius);
                        sp.m_lstpoints.Add(pnt);
                    }
                }

                //indices.resize(rings * sectors * 4);
                //std::vector<GLushort>::iterator i = indices.begin();
                for (int r = 0; r < rings - 1; r++)
                {
                    for (int s = 0; s < sectors - 1; s++)
                    {
                        Polygon p1 = new Polygon();
                        Polygon p2 = new Polygon();
                        sp.m_lstpolys.Add(p1);
                        sp.m_lstpolys.Add(p2);
                        p1.m_points    = new Point3d[3];
                        p2.m_points    = new Point3d[3];
                        p1.m_points[2] = sp.m_lstpoints[r * sectors + s];
                        p1.m_points[1] = sp.m_lstpoints[r * sectors + (s + 1)];
                        p1.m_points[0] = sp.m_lstpoints[(r + 1) * sectors + (s + 1)];

                        p2.m_points[2] = sp.m_lstpoints[(r + 1) * sectors + (s + 1)];
                        p2.m_points[1] = sp.m_lstpoints[(r + 1) * sectors + s];
                        p2.m_points[0] = sp.m_lstpoints[r * sectors + s];
                    }
                }
                sp.Update();
                sp.Rotate(90 * 0.0174532925f, 0, 0);
                sp.Update();
                return(sp);
            }
            catch (Exception ex)
            {
                DebugLogger.Instance().LogError(ex);
                return(null);
            }
        }
예제 #25
0
    bool ListenerParentChange()
    {
//		if(this.name=="Blocks_Head_1"){
//			Debug.Log(" mparent="+ ((m_Parent==null) ? "null ":m_Parent.name));
//		}
        if (oldParent != transform.parent)
        {
            // remove old parent refrence
            if (m_Parent != null && m_Parent is Block)
            {
//				Debug.Log (" remove old parent= " + m_Parent.name);

                Block parentBlock = (Block)m_Parent;

                if (this is Brick)
                {
                    parentBlock.RemoveBrick((Brick)this);
                }
                else if (this is Block)
                {
                    parentBlock.RemoveBlock((Block)this);
                }
            }


            // add to new parent

            Block newParentBlock = null;
            if (transform.parent != null)
            {
                newParentBlock = transform.parent.GetComponent <Block> ();
            }

            if (newParentBlock != null)
            {
                m_Parent = newParentBlock;
                if (this is Brick)
                {
                    newParentBlock.M_Bricks.Add((Brick)this);
                }
                else if (this is Block)
                {
                    newParentBlock.M_Blocks.Add((Block)this);
                }
            }
            else
            {
                m_Parent = null;
            }
            return(true);
        }
//		Debug.Log (" name=" + newParentBlock.m_Time);

        oldParent = transform.parent;
        return(false);
    }
예제 #26
0
 public Object3d(Object3d parent, Vector3 locStartPot, Vector3 locEndPot, int moveDelay, float moveDuration = 1f)
 {
     this.m_Parent       = parent;
     this.m_Loc_StartPot = locStartPot;
     this.m_Loc_EndPot   = locEndPot;
     this.M_Loc_CurPot   = locStartPot;
     this.m_MoveDelay    = moveDelay;
     this.m_MoveDuration = moveDuration;
     this.m_Dirction     = GetDiriction(locStartPot, locEndPot);
 }
예제 #27
0
        private Object3d Intersect(Object3d obj1, Object3d obj2)
        {
            List <csgjs_polygon> a  = ConvertTo(obj1);
            List <csgjs_polygon> b  = ConvertTo(obj2);
            csgjs_csgnode        A  = new csgjs_csgnode(a);
            csgjs_csgnode        B  = new csgjs_csgnode(b);
            csgjs_csgnode        AB = csgjs_csgnode.csg_intersect(A, B);

            return(ConvertFrom(AB.allPolygons()));
        }
예제 #28
0
 public void StartOp(eCSGOp op, Object3d obj1, Object3d obj2)
 {
     m_op   = op;
     m_obj1 = obj1;
     m_obj2 = obj2;
     //m_cancel = false;
     m_runthread = new Thread(new ThreadStart(RunThread), STACKSIZE);
     m_running   = true;
     m_runthread.Start();
 }
예제 #29
0
        /// <summary>
        /// Start the support generation
        /// </summary>
        public void Start(SupportConfig sc, Object3d model)
        {
            Thread m_thread = new Thread(new ThreadStart(StartGenerating));

            m_sc         = sc;
            m_model      = model;
            m_cancel     = false;
            m_generating = true;
            m_thread.Start();
        }
예제 #30
0
 public ISectData(Object3d o, Polygon p, Point3d isect, Point3d orgin, Vector3d dir)
 {
     intersect = new Point3d();
     intersect.Set(isect);
     origin    = new Point3d();
     direction = new Vector3d();
     origin.Set(orgin);
     direction.Set(dir);
     obj  = o;
     poly = p;
 }
예제 #31
0
 // this function takes the object, the slicing parameters,
 // and the output directory. it generates the object slices
 // and saves them in the directory
 public SliceFile Slice(SliceBuildConfig sp, Object3d obj, String outdir)
 {
     m_obj    = obj;
     m_cancel = false;
     // create new slice file
     m_sf          = new SliceFile(sp);
     m_slicethread = new Thread(new ThreadStart(slicefunc));
     m_slicethread.Start();
     isslicing = true;
     return(m_sf);
 }
예제 #32
0
파일: Controller.cs 프로젝트: konlil/pipe
        public virtual void Attach(Object3d entity)
        {
            if(controlled_entity != null)
            {
                Object3d tmp = controlled_entity;
                controlled_entity = null;
                tmp.DetatchController(this);
            }

            controlled_entity = entity;
            entity.AttachController(this);
        }
예제 #33
0
	public bool TriggerBlockMoveIn_ArriveTime (Object3d o3d)
	{
		return moveSpeed.x * o3d.Get_MoveIn_ArriveTime () >= o3d.transform.position.x - transform.position.x;
	}
예제 #34
0
	public bool TriggerBlockMoveOut_LeaveTime (Object3d o3d)
	{
		return moveSpeed.x * o3d.Get_MoveOut_LeaveTime () <= transform.position.x - o3d.M_Max_EndX;
	}
예제 #35
0
	public Object3d (Object3d parent, Vector3 locStartPot, Vector3 locEndPot, int moveDelay, float moveDuration=1f)
	{
		this.m_Parent = parent;
		this.m_Loc_StartPot = locStartPot;
		this.m_Loc_EndPot = locEndPot;
		this.M_Loc_CurPot = locStartPot;
		this.m_MoveDelay = moveDelay;
		this.m_MoveDuration = moveDuration;
		this.m_Dirction = GetDiriction (locStartPot, locEndPot);
	}
예제 #36
0
	public static int SortByBottom (Object3d o1, Object3d o2)
	{
		if (o1 == null) {
			if (o2 == null)
				return 0;
			return 1;
		}
		if (o2 == null)
			return -1;
		int r = o1.M_Loc_CurPot.y .CompareTo (o2.M_Loc_CurPot.y);
		return r;
		
	}
예제 #37
0
	bool ListenerParentChange ()
	{
//		if(this.name=="Blocks_Head_1"){
//			Debug.Log(" mparent="+ ((m_Parent==null) ? "null ":m_Parent.name));
//		}
		if (oldParent != transform.parent) { 
			// remove old parent refrence
			if (m_Parent != null && m_Parent is Block) {
//				Debug.Log (" remove old parent= " + m_Parent.name);

				Block parentBlock = (Block)m_Parent;

				if (this is Brick) {
					parentBlock.RemoveBrick ((Brick)this);
				} else if (this is Block) {
					parentBlock.RemoveBlock ((Block)this);
				}
			}
		

			// add to new parent

			Block newParentBlock = null;
			if (transform.parent != null) 
				newParentBlock = transform.parent.GetComponent<Block> ();

			if (newParentBlock != null) {
				m_Parent = newParentBlock;
				if (this is Brick) {
					newParentBlock.M_Bricks.Add ((Brick)this);
				} else if (this is Block) {
					newParentBlock.M_Blocks.Add ((Block)this);
				}
			} else {
				m_Parent = null;
			}
			return true;
		}
//		Debug.Log (" name=" + newParentBlock.m_Time);

		oldParent = transform.parent;
		return false;
	}
예제 #38
0
	void UpdateWorldPot (Object3d parent)
	{
		if (parent != null) {
			m_StartPot = m_Parent.M_StartPot + m_Loc_StartPot;
			m_EndPot = m_Parent.M_EndPot + m_Loc_EndPot;
			UpdateWorldPot (parent.m_Parent);
		}
	}