Beispiel #1
0
        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();
        }
Beispiel #2
0
        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();
        }
Beispiel #3
0
        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());
        }
Beispiel #4
0
        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);
        }
Beispiel #5
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));
        }
Beispiel #6
0
        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);
        }
Beispiel #7
0
        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());
        }
Beispiel #8
0
        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());
        }
Beispiel #9
0
        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));
        }
Beispiel #10
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);
        }
Beispiel #11
0
        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);
        }
Beispiel #12
0
        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());
        }
Beispiel #13
0
        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);
        }
Beispiel #14
0
        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);
        }
Beispiel #15
0
        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);
        }
Beispiel #16
0
        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));
        }
Beispiel #17
0
        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());
        }
Beispiel #18
0
        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);
        }
Beispiel #19
0
        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);
        }
Beispiel #20
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));
        }
Beispiel #21
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);
        }
Beispiel #22
0
        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();
        }
Beispiel #23
0
        //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);
        }
Beispiel #24
0
        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();
        }
Beispiel #25
0
        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();
        }
Beispiel #26
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);
        }
Beispiel #27
0
        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;
        }
Beispiel #28
0
        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);
            }
        }
Beispiel #29
0
        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);
        }
Beispiel #30
0
        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);
            }
        }
Beispiel #31
0
        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);
        }
Beispiel #32
0
        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);
        }
Beispiel #33
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();
        }
Beispiel #34
0
        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);
        }
Beispiel #35
0
        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);
        }