mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Merge branch 'master' into click
This commit is contained in:
210
samples/Jupyter Notebook/JupyterNotebook.ipynb
Normal file
210
samples/Jupyter Notebook/JupyterNotebook.ipynb
Normal file
File diff suppressed because one or more lines are too long
29
samples/MAXScript/macro-1.mcr
Normal file
29
samples/MAXScript/macro-1.mcr
Normal file
@@ -0,0 +1,29 @@
|
||||
-- Taken from an example from Autodesk's MAXScript reference:
|
||||
-- http://help.autodesk.com/view/3DSMAX/2016/ENU/?guid=__files_GUID_84E24969_C175_4389_B9A6_3B2699B66785_htm
|
||||
|
||||
macroscript MoveToSurface
|
||||
category: "HowTo"
|
||||
(
|
||||
fn g_filter o = superclassof o == Geometryclass
|
||||
fn find_intersection z_node node_to_z = (
|
||||
local testRay = ray node_to_z.pos [0,0,-1]
|
||||
local nodeMaxZ = z_node.max.z
|
||||
testRay.pos.z = nodeMaxZ + 0.0001 * abs nodeMaxZ
|
||||
intersectRay z_node testRay
|
||||
)
|
||||
|
||||
on isEnabled return selection.count > 0
|
||||
|
||||
on Execute do (
|
||||
target_mesh = pickObject message:"Pick Target Surface:" filter:g_filter
|
||||
|
||||
if isValidNode target_mesh then (
|
||||
undo "MoveToSurface" on (
|
||||
for i in selection do (
|
||||
int_point = find_intersection target_mesh i
|
||||
if int_point != undefined then i.pos = int_point.pos
|
||||
)--end i loop
|
||||
)--end undo
|
||||
)--end if
|
||||
)--end execute
|
||||
)--end script
|
||||
53
samples/MAXScript/macro-2.mcr
Normal file
53
samples/MAXScript/macro-2.mcr
Normal file
@@ -0,0 +1,53 @@
|
||||
-- Taken from an example from Autodesk's MAXScript reference:
|
||||
-- http://help.autodesk.com/view/3DSMAX/2016/ENU/?guid=__files_GUID_0876DF46_FAA3_4131_838D_5739A67FF2C1_htm
|
||||
|
||||
macroscript FreeSpline category:"HowTo" tooltip:"FreeSpline" (
|
||||
local old_pos
|
||||
local new_spline
|
||||
local second_knot_set
|
||||
|
||||
fn get_mouse_pos pen_pos old_pen_pos = (
|
||||
if old_pos == undefined then old_pos = old_pen_pos
|
||||
if distance pen_pos old_pos > 10 then
|
||||
(
|
||||
if second_knot_set then
|
||||
addKnot new_spline 1 #smooth #curve pen_pos
|
||||
else
|
||||
(
|
||||
setKnotPoint new_spline 1 2 pen_pos
|
||||
second_knot_set = true
|
||||
)
|
||||
old_pos = pen_pos
|
||||
updateShape new_spline
|
||||
)-- end if
|
||||
)-- end fn
|
||||
|
||||
fn draw_new_line old_pen_pos = (
|
||||
pickPoint mouseMoveCallback:#(get_mouse_pos,old_pen_pos)
|
||||
)
|
||||
|
||||
undo"Free Spline"on(
|
||||
new_spline = splineShape ()
|
||||
old_pen_pos = pickPoint ()
|
||||
|
||||
if old_pen_pos == #RightClick then
|
||||
delete new_spline
|
||||
else
|
||||
(
|
||||
select new_spline
|
||||
new_spline.pos = old_pen_pos
|
||||
addNewSpline new_spline
|
||||
addKnot new_spline 1 #smooth #curve old_pen_pos
|
||||
addKnot new_spline 1 #smooth #curve old_pen_pos
|
||||
second_knot_set = false
|
||||
draw_new_line old_pen_pos
|
||||
q = querybox "Close Spline?" title:"Free Spline"
|
||||
if q then
|
||||
(
|
||||
close new_spline 1
|
||||
updateshape new_spline
|
||||
)
|
||||
select new_spline
|
||||
)--end else
|
||||
)--end undo
|
||||
)--end script
|
||||
64
samples/MAXScript/svg-renderer.ms
Normal file
64
samples/MAXScript/svg-renderer.ms
Normal file
@@ -0,0 +1,64 @@
|
||||
-- Taken from a 3-part tutorial from Autodesk's MAXScript reference
|
||||
-- Source: http://help.autodesk.com/view/3DSMAX/2016/ENU/?guid=__files_GUID_6B5EDC11_A154_4AA7_A972_A11AC36949E9_htm
|
||||
|
||||
fn ColourToHex col = (
|
||||
local theComponents = #(bit.intAsHex col.r, bit.intAsHex col.g, bit.intAsHex col.b)
|
||||
local theValue = "#"
|
||||
for i in theComponents do
|
||||
theValue += (if i.count == 1 then "0" else "") + i
|
||||
theValue
|
||||
)
|
||||
|
||||
local st = timestamp()
|
||||
local theFileName = (getDir #userscripts + "\\PolygonRendering3.svg")
|
||||
local theSVGfile = createFile theFileName
|
||||
format "<svg xmlns=\"http://www.w3.org/2000/svg\"\n" to:theSVGfile
|
||||
format "\t\txmlns:xlink=\"http://www.w3.org/1999/xlink\">\n" to:theSVGfile
|
||||
|
||||
local theViewTM = viewport.getTM()
|
||||
theViewTM.row4 = [0,0,0]
|
||||
|
||||
local theViewTM2 = viewport.getTM()
|
||||
local theViewSize = getViewSize()
|
||||
local theViewScale = getViewSize()
|
||||
theViewScale.x /= 1024.0
|
||||
theViewScale.y /= 1024.0
|
||||
|
||||
local theStrokeThickness = 3
|
||||
|
||||
gw.setTransform (matrix3 1)
|
||||
for o in Geometry where not o.isHiddenInVpt and classof o != TargetObject do (
|
||||
local theStrokeColour = white
|
||||
local theFillColour = o.wirecolor
|
||||
|
||||
local theMesh = snapshotAsMesh o
|
||||
for f = 1 to theMesh.numfaces do (
|
||||
local theNormal = normalize (getFaceNormal theMesh f)
|
||||
|
||||
if (theNormal*theViewTM).z > 0 do
|
||||
(
|
||||
local theFace = getFace theMesh f
|
||||
local v1 = gw.transPoint (getVert theMesh theFace.x)
|
||||
local v2 = gw.transPoint (getVert theMesh theFace.y)
|
||||
local v3 = gw.transPoint (getVert theMesh theFace.z)
|
||||
|
||||
v1.x /= theViewScale.x
|
||||
v1.y /= theViewScale.y
|
||||
v2.x /= theViewScale.x
|
||||
v2.y /= theViewScale.y
|
||||
v3.x /= theViewScale.x
|
||||
v3.y /= theViewScale.y
|
||||
|
||||
format "\t<polygon points='%,% %,% %,%' \n" v1.x v1.y v2.x v2.y v3.x v3.y to:theSVGfile
|
||||
format "\tstyle='stroke:%; fill:%; stroke-width:%'/>\n" (ColourToHex theStrokeColour) (ColourToHex theFillColour) theStrokeThickness to:theSVGfile
|
||||
)--end if normal positive
|
||||
)--end f loop
|
||||
)--end o loop
|
||||
|
||||
format "</svg>\n" to:theSVGfile
|
||||
close theSVGfile
|
||||
local theSVGMap = VectorMap vectorFile:theFileName alphasource:0
|
||||
local theBitmap = bitmap theViewSize.x theViewSize.y
|
||||
renderMap theSVGMap into:theBitmap filter:true
|
||||
display theBitmap
|
||||
format "Render Time: % sec.\n" ((timestamp()-st)/1000.0)
|
||||
22
samples/MAXScript/volume-calc.ms
Normal file
22
samples/MAXScript/volume-calc.ms
Normal file
@@ -0,0 +1,22 @@
|
||||
fn CalculateVolumeAndCentreOfMass obj =
|
||||
(
|
||||
local Volume= 0.0
|
||||
local Centre= [0.0, 0.0, 0.0]
|
||||
local theMesh = snapshotasmesh obj
|
||||
local numFaces = theMesh.numfaces
|
||||
for i = 1 to numFaces do
|
||||
(
|
||||
local Face= getFace theMesh i
|
||||
local vert2 = getVert theMesh Face.z
|
||||
local vert1 = getVert theMesh Face.y
|
||||
local vert0 = getVert theMesh Face.x
|
||||
local dV = Dot (Cross (vert1 - vert0) (vert2 - vert0)) vert0
|
||||
Volume+= dV
|
||||
Centre+= (vert0 + vert1 + vert2) * dV
|
||||
)
|
||||
delete theMesh
|
||||
Volume /= 6
|
||||
Centre /= 24
|
||||
Centre /= Volume
|
||||
#(Volume,Centre)
|
||||
)
|
||||
Reference in New Issue
Block a user