Skip to content

Instantly share code, notes, and snippets.

View JokerMartini's full-sized avatar
😀

John Martini JokerMartini

😀
View GitHub Profile
@JokerMartini
JokerMartini / Generate Random Points On Surface | .ms
Created March 17, 2016 03:17
Maxscript: Generates random points on a targeted surface. Credit Bobo.
fn GenerateRandomPointsOnSurface theObj PointCount useIntersection:true numAttempts:10 =
(
delete $Teapot* --delete previous teapots (remove if you are not making teapots)
local st = timestamp() --get the start time
seed 12345 --set the random seed to a static number to get the same distribution each run
local theMesh = snapshotasMesh theObj --snapshot the TriMesh of the object
local theCount = theMesh.numfaces --get the number of faces in the TriMesh
local theNewObjectsArray = #() --init. an array for the objects to create
local theArea = 0 --init. a variable to hold the count.
@JokerMartini
JokerMartini / Length Of Arc Between Two Points & Radius | .ms
Created March 16, 2016 17:53
Maxscript: This demonstrates how to calculate the length of an arc when the radius and two points are known
-- length = 12.6
-- radius = 10
-- angle 72
-- get arc length
arcLength = 2*pi*10*(72.0/360.0)
-- get arc angle
arcAngle = 360.0 * (2.0/10.0)
@JokerMartini
JokerMartini / Set UVW_Map Gizmo | .ms
Created February 26, 2016 14:23
Maxscript: This demonstrates adding a uvwMap modifier and setting its transform
-- delete objects
-- for y = -10 to 10 do
-- (
-- for x = -10 to 10 do
-- (
-- b = box width:5 height:1 length:5
-- b.pos = [x*5,y*5,0]
-- )
-- )
@JokerMartini
JokerMartini / Save Data to Max File | .ms
Created February 23, 2016 03:16
Maxscript: This demonstrates a simple way to save data to a max file.
CA = attributes MyData
(
parameters main
(
theNames type:#stringTab tabSizeVariable:true
nodes type:#nodeTab tabSizeVariable:true
)
)
--// variant #1 > add to rootNode to store with file
@JokerMartini
JokerMartini / Center Point | .ms
Created February 19, 2016 20:20
Maxscript finds the center point of a mesh.
fn GetCenter pts =
(
local center = [0,0,0]
minPt = copy pts[1]
maxPt = copy pts[1]
for p in pts do
(
/* Find the min pt3 values */
if p.x < minPt.x do minPt.x = p.x
delete objects
theV = normalize [5,0,10] --the vector to rotate, normalized to unit vector
theStep = 180 --the step by which you want to rotate --rotate from 0 to 360-theStep with step TheStep:
for a = 0 to 360-theStep by theStep do
(
rm = rotateZMatrix a --create a rotation matrix from the value
theRotV = theV * rm --transform the original vector using the matrix
format "%: %\n" a theRotV --print the result to Listener
c = cylinder() --create a cylinder
c.dir = theRotV --orient along the vector to see what it looks like
@JokerMartini
JokerMartini / Class Object | .cs
Last active July 5, 2017 14:15
C# class object sample layout
#region privates properties
#endregion privates properties
#region public properties
#endregion public properties
#region constructors
#endregion
#region commands
@JokerMartini
JokerMartini / WPF Path Data | .cs
Last active April 24, 2020 00:57
XAML data paths for C# applications using WPF
// X Symbol
<Path Data="M0,0 L1,1 M0,1 L1,0" Stretch="Uniform" Stroke="Red" />
// Arrow Right
<Path Data="M4.12,0 L9.67,5.47 L4.12,10.94 L0,10.88 L5.56,5.47 L0,0.06" Stretch="Uniform" Fill="Red"/>
// Three Dots
<Path Data="M12.5,6.5 C12.5,9.8137085 9.8137085,12.5 6.5,12.5 C3.1862915,12.5 0.5,9.8137085 0.5,6.5 C0.5,3.1862915 3.1862915,0.5 6.5,0.5 C9.8137085,0.5 12.5,3.1862915 12.5,6.5 z M30.5,6.5 C30.5,9.8137085 27.813708,12.5 24.5,12.5 C21.186292,12.5 18.5,9.8137085 18.5,6.5 C18.5,3.1862915 21.186292,0.5 24.5,0.5 C27.813708,0.5 30.5,3.1862915 30.5,6.5 z M48.5,6.5 C48.5,9.8137085 45.813708,12.5 42.5,12.5 C39.186292,12.5 36.5,9.8137085 36.5,6.5 C36.5,3.1862915 39.186292,0.5 42.5,0.5 C45.813708,0.5 48.5,3.1862915 48.5,6.5 z" Fill="#FFF4F4F5" HorizontalAlignment="Left" Height="13" Margin="23.75,21.75,0,0" Stretch="Fill" Stroke="Black" VerticalAlignment="Top" Width="49"/>
// Paper Airplane
@JokerMartini
JokerMartini / Example Usage | .cs
Last active July 5, 2017 14:15
C# Relay Command classes
private ICommand deleteContactCommand;
public ICommand DeleteContactCommand
{
get
{
return deleteContactCommand ?? (deleteContactCommand = new RelayCommand<Contact>(ExecuteDeleteContact));
}
}
private ICommand deleteSelectedContactsCommand;
@JokerMartini
JokerMartini / Create Empty Mesh Node | .ms
Last active September 18, 2023 09:04
Maxscript: Create an empty mesh node in 3ds Max using maxscript
epoly = convertToPoly (editable_mesh name:(uniquename "EPoly"))