I’ve been testing out a new plugin sandbox for 3ds max created by Ephere. I’ve created some examples that are all realtime captures from the viewport. These are just simplistic examples to illustrate how trivial it is to create new plugins in max using the mentioned sandbox. They are all written using C#.
A simple flocking modifier.
The next one is a conversion of this guy’s Tessendorf water implementation into a modifier in max.
I will upload the source files to these examples when the Lab is released.
captainkeytar have created a nice language definition pack for maxscript in sublime. I added the possibility to execute the scripts from Sublime to 3ds max. Download and installation instructions found here.
I have also created some helper functions for the pflowCylinder script. The main feature is a kd-tree that can be created to help speed up searching for neighboring particles. Files and example scene here. Remember to correct the path to the .dll in the script operator.
The first plugin builds cylinders based on data passed on from maxscript or scripted operators in pflow. The user supplies start and end positions for each cylinder and the plugin builds the corresponding mesh. If you combine this plugin with pflow you can get very cool results. I originally made this to try and mimic the effect from the plexus plugin. The plugin procedurally builds the mesh and you can manipulate the mesh like any other mesh with modifiers and stuff like that. PFlowCylinder
Get the script and some example scenes. here. Remember to have run the script before opening the scenes.
Click for super high res
Pine cone
Pine cone
Based on the pine cone demonstration on wolfram found here. Creates an abstract phyllotaxis object. Download here.
Mouse gestures
I’ve implemented mouse gestures in c# and added it to max. This was before I found out that max have mouse gestures under the name “Gestures”. Max’s version allows you to design your own gestures, but you can only choose the corresponding action from a predefined list (as far as my knowledge goes). My implementation allows you to assign a maxscript to run when a gesture is performed so you can do what you want for each gesture.
Implemented using a nerual network as the classifier, recognizing up to 8 predefined gestures.
To use it, download the .mzp file. Go to customize user interface. Find the mouseGesture category, assign to a button or similar to mouseGestureAssigner, then assign a hotkey to mouseGesture. Then open mouseGestureAssigner with the button you assigned to it and choose the scripts you want to run for the gestures. Download here.
Flow map painter
I started on a flow map painter in c# that i coupled with max to fetch environment data for automatically creating a base flow map for the fetched environment. It’s not done yet, and the flow values are a bit off as you can see in the gif. But it is a cool technique none the less.
A seldom update!
School is hogging all my time so there is not much time to do Max related stuff anymore. Nonetheless, I got three new things to show:
Tetrahedralization in Max using TetGen
A scripted procedural setup in particle flow for rigging ships plowing through ice.
A 2D fluid solver implemented in XNA.
Tetrahedralization in Max using TetGen
I came over this article over at cgtalk and it was an interesting read. The tetrahedralization was new to me, and I started looking at TetGen and how I could interact with it using max. TetGen is a program to generate tetrahedral meshes of any 3D polyhedral domains. TetGen generates exact constrained Delaunay tetrahedralizations, boundary conforming Delaunay meshes, and Voronoi partitions. So I compiled the source files and wrote a maxscript that talks to the cmd line interface using dotNet. The scripts exports a mesh to the .off format, feeds it to TetGen who outputs a .ele and a .node file which Max reads and meshes. The bottleneck is creating the mesh in max. A tip is to check the “Single result mesh”. It gives you a single mesh where the tetrahedrons are created as elements and not as separate nodes. Creating 30K tetrahedrons takes about 4 seconds on my machine when creating as a single mesh. Creating separate nodes for each tetrahedron takes much longer; 4-5K nodes takes 4-5 seconds, 12K nodes takes 40 seconds. So there is a big overhead creating nodes using maxscript.
Cue boring video showing internall structure of a tetgen mesh:
Scripted procedural setup in particle flow for rigging ships plowing through ice.
Got hired to write some scripts to ease the setup and animation of ships plowing through ice.
Some key points for the system:
Support huge scenes > 1k m.
Arbitrary number of agents(boats)
Quick setup/rigging
Easy to make changes / easy iteration => procedural
I came up with some different solutions, but landed on particle flow mixed with agents with custom attributes, mainly because it made it easy to work fully procedural. Doing a rigid body system was out of the question due to the huge scales of the scenes and multiple interactions from the different boats. The user first specifies the number of agents in the system and the scripts creates them. An agent is a shape node with custom attributes linked to helpers for ice crack progagation, ice collision and ice deletion, and parameters for additional settings.
An agent with it's custom attributes
The heart of the system is the particle flow system. It is created after the user have specified the number of agents, which is the only requirement for it to be created. Everything else is customisable. The pflow system consist of mainly four parts: The particle creation, mesh cracking propagation, mesh collision and mesh deletion.
The particle creation is a scripted birth operator sampling mesh objects from the scene to particles. The user writes the common name of the mesh objects to be turned into particles in a custom attribute textfield found on the particle system. Scrubbing the slider now shows the mesh objects being controlled by particles. The original mesh objects are hidden and are not affected. This is because the system needs a reference point for sampling the mesh each time the slider is set back to the starting frame, thus restarting the system.
The next part of the system is the crack propagation check. Each of the agents has a node (by default a sphere deflector) that the pflow setup checks for collision against. If there is a collision the mesh is scaled based on it’s distance to the agent, creating larger cracks near the agents. This is done by a scripted operator.
Showing crack propagation initiated by the largest spherical deflector, the rotated meshes are the objects that collides with the smallest spherical deflector visible in this picture
The third part is the collision with the agent check. If a collision is detected the particles mesh is rotated perpendicular to the collision node referenced by the agent, this could be a custom mesh e.g. a ship hull. This gives the effect of the ice being cracked alongside the ships side. This is also done by a scripted operator.
The last part is the particle deletion check against the agent’s referenced delete node. Particles coming from the previous part are checked againts this node and deleted on collision.
The pflow setup generated by the script using 10 agents.
Seeing it up close it may not look that impressive, but from a distance it gives a nice effect and it’s fully procedural. E.g. changing the path of the boats, changing the crack propagation size or any of the other custom properties are reflected in the system, and it is easy to add custom behavior using the particle view editor.
A little sample video of the system with two agents. I added some debris flying around and noisy push of the ground downwards creating a nice trail:
Since I messed up the vertex colors I applied some gaussian blur to smooth it over
Before the new semester started I decided to do something new and I ended up at looking at fluid solvers. Jos Stam gives this great presentation of his – now over 10 year old – implementation of stable 2D fluids. Converting the solver from C to C# was trivial, though I spent most of the time wrestling with XNA, since it was new to me, to get it to display the fluids correctly.
2D Fluids with the velocity vector field drawn over it
I stumbled over the http://www.qhull.org/ library and it got some really powerfull features like computing convex hulls, Delaunay triangulation and Voronoi diagrams. Decided to try and get some of these features to 3dsmax, so first of is a 2d Voronoi diagram as a geometric object plugin and a convex hull script. Instead of writing a c# wrapper I took an easy workaround piping the output from the cmd window into 3dsmax using .net. I guess there is some extra overhead doing it this way, but compared to the meshing time in max, it is miniscule. For the 2d voronoi diagram you can interactivly change the number of points giving a instantly a new diagram/mesh. On my old pc I can mesh a diagram with 2-3k points interactivly.
The second script using qhull is a standard convex hull generator. I have not tested it against other convex hull generators in max, but I guess it is pretty fast where the meshing part and file IO in 3dsmax is the bottleneck.
I’m planning to add particle support to add points to the 2d voronoi diagram, but I’m having a hard time passing large strings as a argument in the cmd window. For the convex hull I solved it by writing the vertex data to a file and pass that on to qhull. This would not be a good solution for the particles if they are animated, as far as I can see. These two scripts are more like tests than full blow complete scripts, so it may be bugs in them!
Extract all the files to the same location. If you permanently want to install the geometric plugin in you need to place it in the plugins folder as described in the help file, along with the qvoronoi.exe and rbox.exe files
Jigsaw maker
For fun I made a little jigsaw script. Just specify how many pieces you want and optinally draw a template spline for your pieces to generate a fully random jigsaw.
If you want custom pieces, just draw a line following the constraints described in the script’s help button.
Above: The custom spline is displayed to the left.
When created, add a bevel modifier to get the splines meshed.
Using dotnet you can easily send mails from maxscript. I made a simple script that lets the user fill out a form and have it sent to me as a mail.
Just fill in your credentials and be sure to encrypt your script before you deploy it!
Example usage:
Edit:
If you hate having to handle multiple files when dealing with a rather simple script you can fetch supporting files from the web. E.g. say that you have this nice little script you want to share, and you’d want to have the feedback option within the script. The feedback script needs to be in a separate file because you don’t want to expose your credentials. The solution is to fetch the encrypted feedback script from the web by including this function to your script:
A small little utility that lets you embed almost any window that is currently opened.
Automatic switch to the embedded view source code by Denis Trofimov: http://forums.cgsociety.org/showthread.php?t=792214
By request, my first go with dotNet. This script displays a script folder of your choosing in a nice little treeview docked in 3ds max. For features and info click on the image!
So here I was having some fun, calculating some steady two-dimensional heat problems, considering a Dirichlet problem in a rectangZZZZZZzzzz
No, jokes aside, I wrote a new pArticle(!)