private void button2_Click(object sender, EventArgs e) { mmapi_util.RemoteControl rc = new mmapi_util.RemoteControl(); rc.Initialize(); // you could import a mesh using this command: //sc.AppendSceneCommand_AppendMeshFile(...); StoredCommands sc = new StoredCommands(); // [RMS] select entire mesh sc.AppendBeginToolCommand("select"); sc.AppendSelectCommand_All(); // [RMS] start remesh tool sc.AppendBeginToolCommand("remesh"); // [RMS] configure parameters sc.AppendToolParameterCommand("density", 0.2f); sc.AppendToolParameterCommand("smooth", 1.0f); // [RMS] accept result sc.AppendCompleteToolCommand("accept"); sc.AppendCompleteToolCommand("cancel"); // [RMS] to exit out of selection rc.ExecuteCommands(sc); // you could export result using this command //sc.AppendSceneCommand_ExportMeshFile_CurrentSelection(...); rc.Shutdown(); }
private void queriesButton_Click(object sender, EventArgs e) { mmapi_util.RemoteControl rc = new mmapi_util.RemoteControl(); rc.Initialize(); StoredCommands sc = new StoredCommands(); uint resultKey = sc.AppendQueryCommand_GetBoundingBox(); rc.ExecuteCommands(sc); floatArray min = new floatArray(3); floatArray max = new floatArray(3); sc.GetQueryResult_GetBoundingBox(resultKey, min.cast(), max.cast()); float minx = min.getitem(0); float miny = min.getitem(1); float minz = min.getitem(2); float maxx = max.getitem(0); float maxy = max.getitem(1); float maxz = max.getitem(2); Debug.WriteLine("got box"); rc.Shutdown(); }
public List <int> ListSelectedObjects() { StoredCommands sc = new StoredCommands(); uint key = sc.AppendSceneCommand_ListSelectedObjects(); ExecuteCommands(sc); vectori newobjs = new vectori(); sc.GetSceneCommandResult_ListSelectedObjects(key, newobjs); return(newobjs.ToList()); }
public int GetObjectType(int id) { StoredCommands sc = new StoredCommands(); uint key = sc.AppendSceneCommand_GetObjectType(id); ExecuteCommands(sc); any_result a = new any_result(); bool bFound = sc.GetSceneCommandResult_GetObjectType(key, a); return((bFound) ? a.i : -1); }
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)); }
public string GetObjectName(int id) { StoredCommands sc = new StoredCommands(); uint key = sc.AppendSceneCommand_GetObjectName(id); ExecuteCommands(sc); vectorub name = new vectorub(); bool bFound = sc.GetSceneCommandResult_GetObjectName(key, name); return((bFound) ? to_string(name) : null); }
public List <int> ImportFile(string sPath) { StoredCommands sc = new StoredCommands(); uint key = sc.AppendSceneCommand_AppendMeshFile(sPath); ExecuteCommands(sc); vectori objs = new vectori(); sc.GetSceneCommandResult_AppendMeshFile(key, objs); return(objs.ToList()); }
public List <int> ListNewFaceGroups() { StoredCommands sc = new StoredCommands(); uint key = sc.AppendToolQuery_NewGroups(); ExecuteCommands(sc); vectori newobjs = new vectori(); sc.GetToolQueryResult_NewGroups(key, newobjs); return(newobjs.ToList()); }
public float ToScene(float fWorld) { StoredCommands sc = new StoredCommands(); uint key = sc.AppendQueryCommand_ConvertScalarToScene(fWorld); ExecuteCommands(sc); floatArray f = new floatArray(1); sc.GetQueryResult_ConvertScalarToScene(key, f.cast()); return(f.getitem(0)); }
public void ObjectBoundingBox(int objectID, ref AxisAlignedBox3f box) { StoredCommands sc = new StoredCommands(); uint key = sc.AppendQueryCommand_GetObjectBoundingBox(objectID); ExecuteCommands(sc); floatArray min = new floatArray(3), max = new floatArray(3); sc.GetQueryResult_GetBoundingBox(key, min.cast(), max.cast()); box.Min.Set(min); box.Max.Set(max); }
public void SelectionBoundingBox(ref Vector3 Min, ref Vector3 Max) { StoredCommands sc = new StoredCommands(); uint key = sc.AppendQueryCommand_GetBoundingBox(); ExecuteCommands(sc); floatArray min = new floatArray(3), max = new floatArray(3); sc.GetQueryResult_GetBoundingBox(key, min.cast(), max.cast()); Min.Set(min); Max.Set(max); }
private List <int> get_selected_objects(mm.RemoteControl rc) { StoredCommands sc = new StoredCommands(); uint key = sc.AppendSceneCommand_ListSelectedObjects(); rc.ExecuteCommands(sc); vectori v = new vectori(); bool bOK = sc.GetSceneCommandResult_ListSelectedObjects(key, v); return(v.ToList()); }
public int GetTriangleCount(int nObjectID) { StoredCommands sc = new StoredCommands(); uint key = sc.AppendSceneCommand_GetTriangleCount(nObjectID); ExecuteCommands(sc); any_result r = new any_result(); bool bOK = sc.GetSceneCommandResult_GetTriangleCount(key, r); return((bOK) ? r.i : -1); }
public int ListNumberOfHoles() { StoredCommands sc = new StoredCommands(); uint key = sc.AppendQueryCommand_ListNumberOfHoles(); ExecuteCommands(sc); any_result r = new any_result(); sc.GetQueryResult_ListNumberOfHoles(key, r); return(r.i); }
public Vector3f GetVertexPosition(int nObjectID, int nVertexID) { StoredCommands sc = new StoredCommands(); uint key = sc.AppendSceneCommand_GetVertexPosition(nObjectID, nVertexID); ExecuteCommands(sc); vec3f v = new vec3f(); bool bOK = sc.GetSceneCommandResult_GetVertexPosition(key, v); return((bOK) ? g3Extensions.ToVector3f(v) : Vector3f.Invalid); }
public Vector3f SelectedFacesCentroid() { StoredCommands sc = new StoredCommands(); uint key = sc.AppendQueryCommand_GetSelectedFacesCentroid(); ExecuteCommands(sc); floatArray c = new floatArray(3); sc.GetQueryResult_GetSelectedFacesCentroid(key, c.cast()); return(g3Extensions.ToVector3f(c)); }
public List <int> ListSelectedFaceGroups() { StoredCommands sc = new StoredCommands(); uint key = sc.AppendSelectCommand_ListSelectedFaceGroups(); ExecuteCommands(sc); vectori tmp = new vectori(); sc.GetSelectCommandResult_ListSelectedFaceGroups(key, tmp); return(tmp.ToList()); }
static void Main(string[] args) { mmapi_util.RemoteControl rc = new mmapi_util.RemoteControl(); rc.Initialize(); StoredCommands sc = new StoredCommands(); sc.AppendBeginToolCommand("planeCut"); sc.AppendCompleteToolCommand("accept"); rc.ExecuteCommands(sc); }
static void Main(string[] args) { mmapi_util.RemoteControl rc = new mmapi_util.RemoteControl(); rc.Initialize(); StoredCommands sc = new StoredCommands(); sc.AppendBeginToolCommand("planeCut"); sc.AppendCompleteToolCommand("accept"); rc.ExecuteCommands(sc); }
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)); }
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); }
private void button1_Click(object sender, EventArgs e) { mmapi_util.RemoteControl rc = new mmapi_util.RemoteControl(); rc.Initialize(); StoredCommands sc = new StoredCommands(); sc.AppendBeginToolCommand("planeCut"); sc.AppendCompleteToolCommand("accept"); rc.ExecuteCommands(sc); rc.Shutdown(); }
//public int GetObjectType(int nObjectID) //{ // StoredCommands sc = new StoredCommands(); // uint key = sc.AppendSceneCommand_GetObjectType(nObjectID); // ExecuteCommands(sc); // sc.GetSceneCommandResult_GetObjectType(key, ) //} public void SetVisible(int nObjectID, bool bVisible) { StoredCommands sc = new StoredCommands(); if (bVisible) { sc.AppendSceneCommand_SetVisible(nObjectID); } else { sc.AppendSceneCommand_SetHidden(nObjectID); } ExecuteCommands(sc); }
private void button1_Click(object sender, EventArgs e) { mm.RemoteControl rc = new mm.RemoteControl(); rc.Initialize(); StoredCommands sc = new StoredCommands(); sc.AppendBeginToolCommand("planeCut"); sc.AppendCompleteToolCommand("accept"); rc.ExecuteCommands(sc); rc.Shutdown(); }
private void plane_cut_test() { mm.RemoteControl rc = new mm.RemoteControl(); rc.Initialize(); StoredCommands sc = new StoredCommands(); sc.AppendBeginToolCommand("planeCut"); sc.AppendCompleteToolCommand("accept"); rc.ExecuteCommands(sc); rc.Shutdown(); }
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); }
public bool ExecuteCommands(StoredCommands cmd) { BinarySerializer serializer = new BinarySerializer(); cmd.Store(serializer); vectorub commandBuf = serializer.buffer(); byte[] sendBuf = commandBuf.ToArray<byte>(); int nSent = m_pSendSock.Send(sendBuf, sendBuf.Length, m_remoteIP); IPEndPoint remoteIP = new IPEndPoint(IPAddress.Any, 0); byte[] receiveBuf = m_pReceiveSock.Receive(ref remoteIP); vectorub resultBuf = new vectorub(receiveBuf); serializer.setBuffer(resultBuf); cmd.Restore_Results(serializer); return true; }
public int FindObjectByName(string name) { StoredCommands sc = new StoredCommands(); uint key = sc.AppendSceneCommand_FindObjectByName(name); ExecuteCommands(sc); any_result r = new any_result(); bool bOK = sc.GetSceneCommandResult_FindObjectByName(key, r); if (bOK) { return(r.i); } else { return(-1); } }
private void brush_timer_elapsed(object sender, ElapsedEventArgs e) { float height = 0.1f; fAccumTime += fBrushTime; float r0 = 0.1f + fAccumTime * 0.02f; float r1 = 0.1f + (fAccumTime + fBrushTime) * 0.02f; float t0 = fAccumTime * 2.0f; float t1 = (fAccumTime + fBrushTime) * 2.0f; float x0 = r0 * (float)Math.Cos(t0); float y0 = r0 * (float)Math.Sin(t0); float x1 = r1 * (float)Math.Cos(t1); float y1 = r1 * (float)Math.Sin(t1); StoredCommands sc = new StoredCommands(); vec3f v0 = new vec3f(); v0.x = x0; v0.y = height; v0.z = y0; vec3f v1 = new vec3f(); v1.x = x1; v1.y = height; v1.z = y1; sc.AppendActionCommand_LinearBrushStroke3D(v0, v1, 16); mmRemote.ExecuteCommands(sc); }
public void SetVertexColors(int nObjectID, Vector3f[] vColors, int nBatchSize) { int nBatches = vColors.Length / nBatchSize; for (int j = 0; j <= nBatches; ++j) { StoredCommands sc = new StoredCommands(); int iStart = j * nBatchSize; int iUseSize = (j == nBatches) ? (vColors.Length - nBatches * nBatchSize) : nBatchSize; for (int k = 0; k < iUseSize; ++k) { if (vColors[iStart + k] != Vector3f.Invalid) { sc.AppendSceneCommand_SetVertexColor(nObjectID, iStart + k, vColors[iStart + k].toVec3f()); } } ExecuteCommands(sc); } }
public Index3i[] GetTrianglesInRange(int nObjectID, int nTriangleIDStart, int nCount) { StoredCommands sc = new StoredCommands(); uint[] keys = new uint[nCount]; for (int k = 0; k < nCount; ++k) { keys[k] = sc.AppendSceneCommand_GetTriangleIndices(nObjectID, nTriangleIDStart + k); } ExecuteCommands(sc); Index3i[] vTriangles = new Index3i[nCount]; for (int k = 0; k < nCount; ++k) { vec3i v = new vec3i(); bool bOK = sc.GetSceneCommandResult_GetTriangleIndices(keys[k], v); vTriangles[k] = (bOK) ? g3Extensions.ToIndex3i(v) : Index3i.Max; } return(vTriangles); }
public int[] GetFaceGroupsInRange(int nObjectID, int nTriangleIDStart, int nCount) { StoredCommands sc = new StoredCommands(); uint[] keys = new uint[nCount]; for (int k = 0; k < nCount; ++k) { keys[k] = sc.AppendSceneCommand_GetTriangleGroup(nObjectID, nTriangleIDStart + k); } ExecuteCommands(sc); int[] vGroups = new int[nCount]; for (int k = 0; k < nCount; ++k) { any_result r = new any_result(); bool bOK = sc.GetSceneCommandResult_GetTriangleGroup(keys[k], r); vGroups[k] = (bOK) ? r.i : -1; } return(vGroups); }
/* * [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(); }
public bool AttemptPickupItem(GameContext context, GameObjectBase item) { // TODO: this won't work once we have more items that can be picked up CommandPickup commandPickup = (CommandPickup)item; if (commandPickup.CommandId == null) { context.AddError($"{Name} attempts to pick up the command but it vanishes into the void"); return(true); } var command = CommandFactory.CreateCommand(commandPickup.CommandId); if (item.IsCorrupted) { context.AddMessage($"{Name} picks up the corrupted item and is struck by a virus!", ClientMessageType.Failure); var message = context.CombatManager.HurtObject(context, item, this, 3, "infects", DamageType.Combination); context.AddMessage(message, ClientMessageType.Failure); return(true); } int index = HotbarCommands.IndexOf(null); if (index >= 0) { HotbarCommands[index] = CommandFactory.CreateCommandReference(command); context.AddMessage($"{Name} picks up {command.Name}", ClientMessageType.Success); return(true); } index = StoredCommands.IndexOf(null); if (index >= 0) { StoredCommands[index] = CommandFactory.CreateCommandReference(command); context.AddMessage($"{Name} picks up {command.Name} and stores it", ClientMessageType.Success); return(true); } context.AddMessage($"{Name} does not have enough free space to pick up {command.Name}", ClientMessageType.Failure); return(false); }
public bool ExecuteCommands(StoredCommands cmd) { BinarySerializer serializer = new BinarySerializer(); cmd.Store(serializer); vectorub commandBuf = serializer.buffer(); byte[] sendBuf = commandBuf.ToArray <byte>(); int nSent = m_pSendSock.Send(sendBuf, sendBuf.Length, m_remoteIP); IPEndPoint remoteIP = new IPEndPoint(IPAddress.Any, 0); byte[] receiveBuf = m_pReceiveSock.Receive(ref remoteIP); vectorub resultBuf = new vectorub(receiveBuf); serializer.setBuffer(resultBuf); cmd.Restore_Results(serializer); return(true); }