3rd Dimentia
05-07-2009, 06:12 AM
Firstly, thanks for taking the time to read this.
I'm trying to make my first scripted plugin primitive.
I started out by writing a script that would build the object. Which happens to be a soccer ball. I start out with a hedra that I perform a bunch of polyoperations like chamfer,extrude and weld. And then add a bunch of modifiers to finish it off.
So far with the scripted plugin I have it making the hedra at the radius that I'm dragging in the viewport... But when I try to do anything to the hedra in the "on buildMesh do" I get errors. I'm not sure what to try to do next or whether what I'm trying to do is actually even possible.
This is the initial maxscript that actually builds a soccerball. And below that is that start of my scripted plugin that so far only makes a hedra.
Anyone out there got any tips for me?
(
select(hed = hedra radius:10 family:2 scalep:100 scaleq:100 scaler:100 p:0.37 name:"Soccerball")
SetCommandPanelTaskMode #modify
convertTo hed polyMeshObject
hed.faces[#1] = #{1..(polyop.getNumFaces hed)}
hed.edges[#1] = #{1..(polyop.getNumEdges hed)}
hed.verts[#1] = #{1..(polyop.getNumVerts hed)}
subobjectLevel = 1
select hed.verts["1"]
hed.editablePoly.chamferVertices 0.005
subobjectLevel = 2
select hed.edges["1"]
hed.editablePoly.chamferEdges 0.0015
subobjectLevel = 4
for i = 1 to polyop.getNumFaces hed do polyop.setFaceMatID hed i 3
for i = 1 to (hed.faces["1"]).count do polyop.setFaceMatID hed i 1
for i = 1 to (polyop.getNumFaces hed) do
(
if polyop.getFaceMatID hed i == 1 do
(
if (polyop.getfaceVerts hed i).count == 10 do
(
polyop.setFaceMatID hed i 2
)
)
)
faceSel = #()
for i = 1 to (polyop.getNumFaces hed) do
(
if polyop.getFaceMatID hed i == 1 or polyop.getFaceMatID hed i == 2 then append faceSel i
)
hed.selectedFaces = faceSel
hed.extrudeFaces 0.5
hed.EditablePoly.ConvertSelection #Face #Vertex
subobjectLevel = 1
closestVerts = (distance (polyop.getvert hed (hed.selectedVerts[1].index)) (polyop.getVert hed (hed.selectedVerts[2].index)))
vert1 = 1
vert2 = 2
for i = 1 to 6 /*hed.selectedVerts.count*/ do
(
for j = i to 6 /*hed.selectedVerts.count*/ do
(
if j != i do
(
testDist = (distance (polyop.getvert hed (hed.selectedVerts[i].index)) (polyop.getVert hed (hed.selectedVerts[j].index)))
if testDist < closestVerts do
(
closestVerts = testDist
vert1 = (hed.selectedVerts[i].index)
vert2 = (hed.selectedVerts[j].index)
)
)
)
)
--format "closest Verts = % % %\n"vert1 vert2 closestVerts
hed.weldThreshold = closestVerts*2
polyop.weldVertsByThreshold hed hed.selectedVerts
suspendEditing()
ms = meshsmooth iterations:2
addmodifier hed ms
sp = spherify percent:100
addmodifier hed sp
vs = Vol__Select level:2 volume:5 matID:3
addmodifier hed vs
psh = push push_Value:-.125
addmodifier hed psh
vs = Vol__Select level:2 volume:5 matID:3 invert:on
addmodifier hed vs
rel = relax Relax_Value:1 Keep_Boundary_Pts_Fixed:0 iterations:1
addmodifier hed rel
ps = poly_Select()
addmodifier hed ps
ms = meshsmooth iterations:1
--addmodifier hed ms
maxops.collapseNodeTo hed 1 false
update hed
theMultiMat = multimaterial name:"SoccerBall" numsubs:3
theMultiMat[1] = standard diffuse:white
theMultiMat[2] = standard diffuse:black
theMultiMat[3] = standard diffuse:black
hed.material = theMultiMat
resumeEditing()
)
plugin SimpleObject Soccerball
name:"Soccerball"
classID:#(0xd2469fb, 0x5913a0fd)
category:"CgRay"
(
parameters main rollout:params
(
radius type:#float default:10 ui:spn_radius
)
rollout params "Parameters"
(
spinner spn_radius "Radius" range:[0.01,100000,0]
)
on buildMesh do
(
Soccerball = createInstance hedra radius:radius family:2 scalep:100 scaleq:100 scaler:100 p:0.37 name:"Soccerball"
mesh = Soccerball.mesh
)
tool create
(
on mousePoint click do
(
case click of
(
1: nodeTM.translation = gridPoint
2: #stop
)
)
on mouseMove click do
(
case click of
(
2: ( radius = (abs gridDist.x + abs gridDist.y)/2)
)
)
)
)
I'm trying to make my first scripted plugin primitive.
I started out by writing a script that would build the object. Which happens to be a soccer ball. I start out with a hedra that I perform a bunch of polyoperations like chamfer,extrude and weld. And then add a bunch of modifiers to finish it off.
So far with the scripted plugin I have it making the hedra at the radius that I'm dragging in the viewport... But when I try to do anything to the hedra in the "on buildMesh do" I get errors. I'm not sure what to try to do next or whether what I'm trying to do is actually even possible.
This is the initial maxscript that actually builds a soccerball. And below that is that start of my scripted plugin that so far only makes a hedra.
Anyone out there got any tips for me?
(
select(hed = hedra radius:10 family:2 scalep:100 scaleq:100 scaler:100 p:0.37 name:"Soccerball")
SetCommandPanelTaskMode #modify
convertTo hed polyMeshObject
hed.faces[#1] = #{1..(polyop.getNumFaces hed)}
hed.edges[#1] = #{1..(polyop.getNumEdges hed)}
hed.verts[#1] = #{1..(polyop.getNumVerts hed)}
subobjectLevel = 1
select hed.verts["1"]
hed.editablePoly.chamferVertices 0.005
subobjectLevel = 2
select hed.edges["1"]
hed.editablePoly.chamferEdges 0.0015
subobjectLevel = 4
for i = 1 to polyop.getNumFaces hed do polyop.setFaceMatID hed i 3
for i = 1 to (hed.faces["1"]).count do polyop.setFaceMatID hed i 1
for i = 1 to (polyop.getNumFaces hed) do
(
if polyop.getFaceMatID hed i == 1 do
(
if (polyop.getfaceVerts hed i).count == 10 do
(
polyop.setFaceMatID hed i 2
)
)
)
faceSel = #()
for i = 1 to (polyop.getNumFaces hed) do
(
if polyop.getFaceMatID hed i == 1 or polyop.getFaceMatID hed i == 2 then append faceSel i
)
hed.selectedFaces = faceSel
hed.extrudeFaces 0.5
hed.EditablePoly.ConvertSelection #Face #Vertex
subobjectLevel = 1
closestVerts = (distance (polyop.getvert hed (hed.selectedVerts[1].index)) (polyop.getVert hed (hed.selectedVerts[2].index)))
vert1 = 1
vert2 = 2
for i = 1 to 6 /*hed.selectedVerts.count*/ do
(
for j = i to 6 /*hed.selectedVerts.count*/ do
(
if j != i do
(
testDist = (distance (polyop.getvert hed (hed.selectedVerts[i].index)) (polyop.getVert hed (hed.selectedVerts[j].index)))
if testDist < closestVerts do
(
closestVerts = testDist
vert1 = (hed.selectedVerts[i].index)
vert2 = (hed.selectedVerts[j].index)
)
)
)
)
--format "closest Verts = % % %\n"vert1 vert2 closestVerts
hed.weldThreshold = closestVerts*2
polyop.weldVertsByThreshold hed hed.selectedVerts
suspendEditing()
ms = meshsmooth iterations:2
addmodifier hed ms
sp = spherify percent:100
addmodifier hed sp
vs = Vol__Select level:2 volume:5 matID:3
addmodifier hed vs
psh = push push_Value:-.125
addmodifier hed psh
vs = Vol__Select level:2 volume:5 matID:3 invert:on
addmodifier hed vs
rel = relax Relax_Value:1 Keep_Boundary_Pts_Fixed:0 iterations:1
addmodifier hed rel
ps = poly_Select()
addmodifier hed ps
ms = meshsmooth iterations:1
--addmodifier hed ms
maxops.collapseNodeTo hed 1 false
update hed
theMultiMat = multimaterial name:"SoccerBall" numsubs:3
theMultiMat[1] = standard diffuse:white
theMultiMat[2] = standard diffuse:black
theMultiMat[3] = standard diffuse:black
hed.material = theMultiMat
resumeEditing()
)
plugin SimpleObject Soccerball
name:"Soccerball"
classID:#(0xd2469fb, 0x5913a0fd)
category:"CgRay"
(
parameters main rollout:params
(
radius type:#float default:10 ui:spn_radius
)
rollout params "Parameters"
(
spinner spn_radius "Radius" range:[0.01,100000,0]
)
on buildMesh do
(
Soccerball = createInstance hedra radius:radius family:2 scalep:100 scaleq:100 scaler:100 p:0.37 name:"Soccerball"
mesh = Soccerball.mesh
)
tool create
(
on mousePoint click do
(
case click of
(
1: nodeTM.translation = gridPoint
2: #stop
)
)
on mouseMove click do
(
case click of
(
2: ( radius = (abs gridDist.x + abs gridDist.y)/2)
)
)
)
)
