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); }
/* * [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(); }
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(); }