Example #1
0
 public mmFrame(frame3f f)
 {
     origin = new Vector3f(f.origin_x, f.origin_y, f.origin_z);
     x      = new Vector3f(f.tan1_x, f.tan1_y, f.tan1_z);
     y      = new Vector3f(f.tan2_x, f.tan2_y, f.tan2_z);
     z      = new Vector3f(f.normal_x, f.normal_y, f.normal_z);
 }
Example #2
0
        private void pivotTransformButton_Click(object sender, EventArgs e)
        {
            mm.RemoteControl rc = new mm.RemoteControl();
            rc.Initialize();

            // in world units
            Vector3f frameTranslation = new Vector3f(0, 0, 20);

            int objectID = get_object_id(rc, "object");
            int pivotID  = get_object_id(rc, "pivot");

            List <int> selected = get_selected_objects(rc);

            System.Diagnostics.Debug.Assert(selected != null && selected.Count == 1 && selected[0] == objectID, "the mesh you want to move must be selected");

            frame3f  pivotFrame       = get_pivot_frame(rc, pivotID);
            Vector3f x                = new Vector3f(pivotFrame.tan1_x, pivotFrame.tan1_y, pivotFrame.tan1_z);
            Vector3f y                = new Vector3f(pivotFrame.tan2_x, pivotFrame.tan2_y, pivotFrame.tan2_z);
            Vector3f z                = new Vector3f(pivotFrame.origin_x, pivotFrame.origin_y, pivotFrame.origin_z);
            Vector3f worldTranslation = frameTranslation[0] * x
                                        + frameTranslation[1] * y + frameTranslation[2] * z;

            vec3f translate = worldTranslation.toVec3f();

            StoredCommands sc = new StoredCommands();

            sc.AppendBeginToolCommand("transform");
            sc.AppendToolParameterCommand("translationWorld", translate);
            rc.ExecuteCommands(sc);


            rc.Shutdown();
        }
Example #3
0
        public void SetObjectFrame(int id, mmFrame newFrame)
        {
            frame3f        f  = newFrame.toFrame3f();
            StoredCommands sc = new StoredCommands();

            sc.AppendSceneCommand_SetObjectFrame(id, f);
            ExecuteCommands(sc);
        }
Example #4
0
        public frame3f toFrame3f()
        {
            frame3f f = new frame3f();

            f.origin_x = origin[0]; f.origin_y = origin[1]; f.origin_z = origin[2];
            f.tan1_x   = x[0]; f.tan1_y = x[1]; f.tan1_z = x[2];
            f.tan2_x   = y[0]; f.tan2_y = y[1]; f.tan2_z = y[2];
            f.normal_x = z[0]; f.normal_y = z[1]; f.normal_z = z[2];
            return(f);
        }
Example #5
0
        private frame3f get_pivot_frame(mm.RemoteControl rc, int pivotID)
        {
            StoredCommands sc  = new StoredCommands();
            uint           key = sc.AppendSceneCommand_GetObjectFrame(pivotID);

            rc.ExecuteCommands(sc);
            frame3f f   = new frame3f();
            bool    bOK = sc.GetSceneCommandResult_GetObjectFrame(key, f);

            return(f);
        }
Example #6
0
        private Vector3f get_pivot_location(mm.RemoteControl rc, int pivotID)
        {
            StoredCommands sc  = new StoredCommands();
            uint           key = sc.AppendSceneCommand_GetObjectFrame(pivotID);

            rc.ExecuteCommands(sc);
            frame3f f   = new frame3f();
            bool    bOK = sc.GetSceneCommandResult_GetObjectFrame(key, f);

            return(new Vector3f(f.origin_x, f.origin_y, f.origin_z));
        }
Example #7
0
        public mmFrame GetObjectFrame(int id)
        {
            StoredCommands sc  = new StoredCommands();
            uint           key = sc.AppendSceneCommand_GetObjectFrame(id);

            ExecuteCommands(sc);
            frame3f f = new frame3f();

            sc.GetSceneCommandResult_GetObjectFrame(key, f);
            return(new mmFrame(f));
        }
Example #8
0
        public mmFrame NearestSurfacePoint(Vector3f queryPt)
        {
            StoredCommands sc  = new StoredCommands();
            uint           key = sc.AppendQueryCommand_FindNearestPoint(queryPt[0], queryPt[1], queryPt[2]);

            ExecuteCommands(sc);

            frame3f f = new frame3f();

            sc.GetQueryResult_FindNearestPoint(key, f);
            return(new mmFrame(f));
        }
Example #9
0
        public int CreatePivot()
        {
            StoredCommands sc  = new StoredCommands();
            frame3f        f   = WorldFrame();
            uint           key = sc.AppendSceneCommand_CreatePivot(f);

            ExecuteCommands(sc);

            any_result r = new any_result();

            sc.GetSceneCommandResult_CreatePivot(key, r);
            return(r.i);
        }
Example #10
0
        public frame3f WorldFrame()
        {
            frame3f  f        = new frame3f();
            Vector3f vOriginS = ToScene(new Vector3f(0, 0, 0));

            f.origin_x = vOriginS[0]; f.origin_y = vOriginS[1]; f.origin_z = vOriginS[2];

            f.tan1_x   = 1.0f; f.tan1_y = 0.0f; f.tan1_z = 0.0f;
            f.tan2_x   = 0.0f; f.tan2_y = 0.0f; f.tan2_z = 1.0f;
            f.normal_x = 0.0f; f.normal_y = 1.0f; f.normal_z = 0.0f;

            return(f);
        }
Example #11
0
        public bool FindRayIntersection(Vector3f o, Vector3f d, ref Vector3f vHit)
        {
            StoredCommands sc  = new StoredCommands();
            uint           key = sc.AppendQueryCommand_FindRayIntersection(o[0], o[1], o[2], d[0], d[1], d[2]);

            ExecuteCommands(sc);
            frame3f frame = new frame3f();
            bool    bHit  = sc.GetQueryResult_FindRayIntersection(key, frame);

            if (bHit)
            {
                vHit = new Vector3f(frame.origin_x, frame.origin_y, frame.origin_z);
            }
            return(bHit);
        }
Example #12
0
        /*
         *  [RMS] test code for dropping solid parts
         */

        private void drop_part_test_1()
        {
            mm.RemoteControl rc = new mm.RemoteControl();
            rc.Initialize();


            // [RMS] use a raycast to get an initial drop point for the part
            StoredCommands raycast_cmd = new StoredCommands();
            vec3f          ray_o       = new vec3f();

            ray_o.x = 0.0f; ray_o.y = 0.0f; ray_o.z = -100.0f;
            vec3f ray_d = new vec3f();

            ray_d.x = 0.0f; ray_d.y = 0.0f; ray_d.z = 1.0f;
            uint rayhit_key = raycast_cmd.AppendQueryCommand_FindRayIntersection(ray_o, ray_d);

            rc.ExecuteCommands(raycast_cmd);
            frame3f f    = new frame3f();
            bool    bHit = raycast_cmd.GetQueryResult_FindRayIntersection(rayhit_key, f);

            System.Diagnostics.Debug.Assert(bHit);

            // begin the interactive part drop. Note that the path is hardcoded to the part .obj file, however
            // the type of slash doesn't matter, we handle that internally
            StoredCommands drop_part_cmd = new StoredCommands();

            drop_part_cmd.AppendActionCommand_DropSolidPartAtPoint(
                "C:\\Users\\schmidr\\Documents/meshmixer\\libraries\\parts\\default\\Primitives\\1397485517_00001_cone.obj",
                //                "C:/GitHub/meshmixer/meshmixer_devel/libraries\\parts\\default\\Primitives\\1397485517_00001_cone.obj",
                f, 0.0f, true);
            drop_part_cmd.AppendToolParameterCommand("operationType", 0);
            rc.ExecuteCommands(drop_part_cmd);


            // accept the drop position
            //StoredCommands accept_cmd = new StoredCommands();
            //accept_cmd.AppendActionCommand_AcceptDropPart();
            //rc.ExecuteCommands(accept_cmd);


            rc.Shutdown();
        }
Example #13
0
        private void drop_part_test_2()
        {
            mm.RemoteControl rc = new mm.RemoteControl();
            rc.Initialize();


            // [RMS] use a raycast to get an initial drop point for the part
            StoredCommands raycast_cmd = new StoredCommands();
            vec3f          ray_o       = new vec3f();

            ray_o.x = 0.0f; ray_o.y = 0.0f; ray_o.z = -100.0f;
            vec3f ray_d = new vec3f();

            ray_d.x = 0.0f; ray_d.y = 0.0f; ray_d.z = 1.0f;
            uint rayhit_key = raycast_cmd.AppendQueryCommand_FindRayIntersection(ray_o, ray_d);

            rc.ExecuteCommands(raycast_cmd);
            frame3f f    = new frame3f();
            bool    bHit = raycast_cmd.GetQueryResult_FindRayIntersection(rayhit_key, f);

            System.Diagnostics.Debug.Assert(bHit);

            StoredCommands drop_part_cmd2 = new StoredCommands();

            drop_part_cmd2.AppendActionCommand_DropSolidPartAtPoint(
                "C:/Users/schmidr/Documents/meshmixer/libraries/parts/user/My Parts/1469555765_00001_solidWatchTest.obj", f, 0.0f, true);
            drop_part_cmd2.AppendToolParameterCommand("operationType", 0);
            rc.ExecuteCommands(drop_part_cmd2);

            // accept the drop position
            //StoredCommands accept_cmd = new StoredCommands();
            //accept_cmd.AppendActionCommand_AcceptDropPart();
            //rc.ExecuteCommands(accept_cmd);

            rc.Shutdown();
        }