Notifications
Clear all

[Closed] Scripted SimpleObject Plug-ins – (moving inside it)

IUUUJJJUUUUUU!
thanks God (Bobo) it works:

 plugin simpleObject Column 
name:"Column"
classID:#(63446,55333)
category:"3DEmpire" ( 
local cyl1, cyl2, cyl3, box1, tempMesh1, tempMesh2, tempMesh3
parameters main rollout:params (
radius type:#worldUnits ui:radius default:0.3 
height type:#worldUnits ui:height default:2.4 
zocHeight type:#float ui:zocHeight default: 0.1 
zocWidth type:#float ui:zocWidth default: 0.2 
radiosity type:#boolean ui:radiosity
)
fn assignMatID theMesh IDnum = (
for f = 1 to theMesh.numfaces do setFaceMatID theMesh f IDnum 
)
fn transformMesh theTriMesh theMatrix = (
for v = 1 to theTriMesh.numverts do
setVert theTriMesh v ((getVert theTriMesh v)*theMatrix)
theTriMesh
)
fn deleteFacesLookingUpDown theTriMesh lookVect = (
for vect in lookVect do (
for f = theTriMesh.numfaces to 1 by -1 do (
theNormal = getFaceNormal theTriMesh f
-- delete faces looking up/down
if acos(dot theNormal vect) == 0 do deleteFace theTriMesh f 
)
)
)
rollout params "Column" (
group "Dimensions" (
spinner radius "radius" type:#worldUnits range:[0.0,1E9,1E-3]
spinner height "height" type:#worldUnits range:[0.0,1E9,1E-3]
)
group "Zocalo" (
spinner zocHeight "height" type:#float range:[0.0,1E9,1E-3] 
spinner zocWidth "width" type:#float range:[0.0,1E9,1E-3]
)
group "Parameters" (
checkbutton radiosity "Radiosity" checked:false tooltip:"Increase the number of polygons"
)
)
on buildMesh do (
if cyl1 == undefined then (
cyl1 = createInstance cylinder heightsegs: 1
cyl2 = createInstance cylinder heightsegs: 1 sides: 18 smooth:true realWorldMapSize: on
box1 = createInstance box lengthsegs: 3 widthsegs: 3 height: 0.0
)
if radiosity == on then cyl2.heightsegs = 5 else cyl2.heightsegs = 1
 
cyl1.height = zocHeight ; cyl2.height = height - zocHeight 
cyl2.radius = radius
cyl1.radius = radius + zocWidth 
box1.width = box1.length = radius * 2 * 1.1
tempMesh1 = cyl1.mesh
tempMesh2 = cyl2.mesh 
tempMesh3 = box1.mesh 
assignMatID tempMesh1 3
assignMatID tempMesh2 4
assignMatID tempMesh3 5
 
deleteFacesLookingUpDown tempMesh1 #([0,0,-1])
deleteFacesLookingUpDown tempMesh2 #([0,0,1],[0,0,-1])
deleteFacesLookingUpDown tempMesh3 #([0,0,1])
tempMesh2 = transformMesh tempMesh2 (matrix3 [1,0,0] [0,1,0] [0,0,1] [0,0,this.zocHeight]) 
tempMesh3 = transformMesh tempMesh3 (matrix3 [1,0,0] [0,1,0] [0,0,1] [0,0,this.height])
 
mesh = tempMesh2.mesh + tempMesh1.mesh + tempMesh3.mesh
 
delete tempMesh1
delete tempMesh2
delete tempMesh3 
)
tool create (
on mousePoint click do
case click of (
1: nodeTM.translation = gridPoint
5: #stop
)
 
on mouseMove click do
case click of (
2: radius = abs gridDist.x
3: height = abs gridDist.z
4: zocHeight = if (abs gridDist.z < height) then abs gridDist.z else height
5: zocWidth = abs gridDist.x
)
 
)
)

I will follow improving it till the end…

Next steps:
1- create an array of columns, joining them at bottom and top with two elements of the same mesh: floor and ceiling.
As manual example shows with boxes at: Creating Maxscript Tools > Scripted Plug-ins

2- change shape between square and circle.

Bobo: I will never ask you again how to add a modifier inside a scripted geometry plugin .

homework almost done:

Modifying the script in the Maxscript reference manual, at:

Creating Maxscript Tools > Scripted Plug-ins > Scripted Geometry Plug-ins > Example

I can create Instances of a box with this:

 
plugin geometry foo_plugin_def
name:"FooBar"
category:"Scripted Primitives" ( 
local boxes = #(), clickAt
tool create (
on mousePoint click do (
clickAt = worldPoint
boxes[1] = box pos:[1,0,0]
for i in 1 to 9 do (
append boxes (instance boxes[1])
boxes[i].pos = [i*20,0,0] + clickAt
)
#stop
)
)
rollout frab "Parameters" (
spinner frab_value "Frabulate" range:[-1000,1000,20]
on frab_value changed val do
for i in 1 to 10 do boxes[i].pos = [i*val,0,0] + clickAt
)
)

Is it possible to insert my Scripted plugin inside a similar code to create instances of my Column?

This way I will obtain an array of my column, may be with 20 or 30 instances.
Perhaps too much to ask for a simple scripted plugin…

Thanks in advance.

Hey! my lastest discovery.
With the plugin installed:

 showClass "Column.*"

lists all the properties of this new geometry:

 
Column : GeometryClass {f7d6,d825}
.radius : worldUnits
.height : worldUnits
.zocHeight : float
.zocWidth : float
.Radiosity : boolean
OK

And

 b = column pos:[1,0,0] heigth:3 radius:.2 zocHeight:.1 zocWidth:0.02

Will create a column with this values.
Not bad…

SO…:

 
plugin geometry foo_plugin_def
name:"FooBar"
category:"Scripted Primitives" ( 
local columns = #(), clickAt
tool create (
on mousePoint click do (
 clickAt = worldPoint
 columns[1] = column pos:[1,0,0] heigth:3 radius:.2 zocHeight:.1 zocWidth:0.02
 for i in 1 to 9 do (
  append columns (instance columns[1])
  columns[i].pos = [i*20,0,0] + clickAt
 )
 #stop
)
)
rollout frab "Parameters" (
spinner frab_value "Frabulate" range:[-100,100,5]
on frab_value changed val do
 for i in 1 to 10 do columns[i].pos = [i*val,0,0] + clickAt
)
)

Will create 10 Columns (instances) with 5 meters between each

IT WORKS!

Page 2 / 2