Skip to content

Instantly share code, notes, and snippets.

View JokerMartini's full-sized avatar
😀

John Martini JokerMartini

😀
View GitHub Profile
@JokerMartini
JokerMartini / Scale Verts | .ms
Created August 20, 2015 14:51
Maxscript: This demonstrates how to scale a set of verts based on a transform/center point.
/* Scene Setup */
delete objects
ref = plane width:100 length:100 widthsegs:1 lengthsegs:1 wirecolor:yellow pos:[0,0,-1]
obj = convertToPoly (snapshot ref)
obj.pos = [0,0,0]
/* Scale Verts */
sca = [0.9, 0.9, 0.9]
-- array of vert positions
@JokerMartini
JokerMartini / Simple Primitive | .ms
Created August 20, 2015 15:51
Maxscript: This snippet demonstrates a simple plane primitive plugin for 3ds Max.
plugin simpleObject quad
name:"Quad"
category:"Training Primitives"
classID:#(0x4927806d, 0x3d9ca278)
(
parameters main rollout:params
(
width type:#float ui:width default:0
length type:#float ui:length default:0
@JokerMartini
JokerMartini / Noise Distortion | .ms
Created August 20, 2015 16:37
Maxscript: This demonstrates how to apply a noise distortion to mathematical values.
try(destroyDialog rlTest)catch()
rollout rlTest "test"
(
spinner uiWidth "Width" range:[-1e6,1e6,300.0] type:#worldUnits
spinner uiHeight "Height" range:[-1e6,1e6,50.0] type:#worldUnits
spinner uiSamples "Samples" range:[1,1e4,100] type:#integer
group "Noise"
(
spinner uiNoiseFrequency "Frequency" range:[0,1e9,.1] type:#float scale:0.01
spinner uiNoisePhase "Phase" range:[-1e9,1e9,1.0] type:#float scale:0.1
@JokerMartini
JokerMartini / Formatted with leading Zeros | .ms
Created August 26, 2015 11:49
Maxscript: Creates a string with leading zeros.
formattedPrint 2 format:"3.3d"
@JokerMartini
JokerMartini / Select Faces Within Angle Threshold | .ms
Created September 4, 2015 12:16
Maxscript: Selects the faces of an editable poly within a given angle threshold from the Z normal. There is a max height parameter which ignores faces lower than the Max Height value.
--"Angle Threshold spinner" -- angle beetven face normal and Z-axis
--"Max Height" -- select only faces which center position is > Max Height
try(DestroyDialog ::bgaRoll)catch()
rollout bgaRoll "selectObjTops"
(
local poGFN = polyop.getFaceNormal, poGFC = polyop.getFaceCenter
spinner spn_ang "Angle Threshold:" range:[0,360,5] pos:[5,5]
spinner spn_heig "Max Height: " range:[0,360,0] pos:[4,25]
button btn "Select T O P S!" width:150 pos:[5,45]
@JokerMartini
JokerMartini / Generate Points with PFlow | .ms
Created September 4, 2015 12:18
Maxscript: Demonstrates how to use Pflow to generate points on polygonal nodes.
global _genPFPts = #()
fn GenPFPoints nodes:undefined amount:10 location:4 =
(
_genPFPts = #()
pfp = PF_Source name:"pf_points" X_Coord:0 Y_Coord:0 Quantity_Viewport:100 Show_Logo:off Show_Emitter:off
particleFlow.BeginEdit()
op1 = Birth name:"pfp_birth" amount:amount Emit_Stop:currenttime Emit_Start:currenttime
@JokerMartini
JokerMartini / Generate Points Then Align Object | .ms
Created October 8, 2015 11:41
Maxscript: Takes an array containing X number of point3 values (no less then 3 points) and aligns an object at the center location of those points. Then aligns the object so it's X-axis is pointing at the first item in that point3 array and the Z axis is point outward from those points (like a local axis) We need at least two vectors to make a m…
fn GenerateCircularPoints spaced:true count:10 radius:12 =
(
pts = if spaced then
(
for k=1 to count collect (text size:4 axistripod:off pos:[radius * cos((k-1) * (360.0 / count)), radius * sin((k-1) * (360.0 / count)),0] wirecolor:yellow text:(k as string))
)else(
for k=1 to count collect (text size:4 axistripod:off pos:[radius*cos(a = random 0 360), radius*sin(a),0] wirecolor:yellow text:(k as string))
)
pts
)
@JokerMartini
JokerMartini / Loop Through Directories Building Tree | .cs
Last active July 5, 2017 14:18
C#: This snippet is used to search through a directory and build a treeview list of nodes
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
@JokerMartini
JokerMartini / Timestamping Data | .ms
Created October 22, 2015 18:31
Maxscript: This snippet demonstrates how to timestamp memory and execution time.
--Info Logging Start
clearlistener()
RunStartTime = (timestamp())
RunStartMemory = heapfree
-- Function goes here
--Info Logging End
RunEndTime = (timestamp())
RunEndMemory = heapfree
@JokerMartini
JokerMartini / Saving Scene Nodes To XML | .ms
Created October 26, 2015 18:41
Maxscript: Saves the current 3ds Max scene nodes and various object properties to an XML.
clearlistener()
delete objects
--// create test scene
fn testSceneSetup =
(
local nodeCount = 100
for i = 1 to nodeCount do
(