Notifications
Clear all

[Closed] Interactive Solver C#

Greetings

I’m back in the 3ds Max world after a bit of a break, and am about to sink my teeth into a new project.

I’m trying to implement some features from a 3rd party physics API (DotNet), and as I’m starting from scratch, thought I’d see how other folks do this sort of thing – in broad brush strokes.

So far, as a proof of concept, I’ve created a physics solver class instance from the API, populated it with equivalent objects based on selected 3ds Max scene objects, set their constraints and various solver properties, and the initial state for the simulation. This is using a mix of maxscript, and C#.

So then on time change, the simulation time in the API is stepped forward the appropriate number of ms. and simulated objects’ transforms are calculated and applied back to scene objects, At the moment this is just by setting the INode position (or SetNodeTM) directly, and forcing a viewport refresh.

In interactive mode, I’m just running a timer, and on each tick advancing the API simulation time, and calculating the resultant simulated object positions. Again, just setting the INode positions from dotNet, and forcing a viewport refresh.

The results of the proof of concept were positive, the math works, and all the objects move and update as expected. Now I just need to somehow make it deployable and robust enough for in-house use.

My main issues are:

a) driving the position or Transform matrix directly is hacky, but I’m not sure if there is a way to make your own point3 or matrix controller with C# yet? (2016 SP3)
b) framerate and GUI responsiveness is poor in interactive mode (not due to underlying computation time – probably from viewport refreshes?)
c) stability in interactive mode is poor, i.e. dragging objects too far before letting go of the mouse imports far too much instantaneous force into the calculation, and the dependent objects fly off. I guess I need better mouse/dragging handling?

And thoughts or advice out there?

Cheers

Mikie

2 Replies
1 Reply
(@aaandres)
Joined: 10 months ago

Posts: 0

Hi Mikie. Your plugin sounds nice.
I can’t help you very much but, at least for a) item: for example to add a Point3 expression controller to ‘myNode’ position:

            static public IGlobal global = GlobalInterface.Instance;
            static public IInterface14 ip = global.COREInterface14;

            IClass_ID cid = global.Class_ID.Create((uint)BuiltInClassIDA.EXPR_P3_CONTROL_CLASS_ID, 0);
            IControl ctrl = ip.CreateInstance(SClass_ID.CtrlPoint3, cid) as IControl;
            myNode.TMController.AssignController(ctrl, 0);

Cheers! That’s indeed useful