View Full Version : Simple object plugin trimesh as parameter problem
12-17-2008, 01:09 PM
I'm having difficulty getting the hang of how to handle meshes in a simple-object plugin.
What parameter type do I have to use for a trimesh? I assume its a #maxobject. The weird thing is if I use the following code and enter it manually in the listener, themesh takes on the box trimesh. Running it from the script causes themesh to remain undefined.... I can't work out whats wrong with what Im doing.
plugin simpleObject someobject
fn buildsomething = (
this.themesh = snapshotasmesh (box())
setmesh mesh this.themesh
parameters main rollout:params
rollout params "Source Objects"
on buildMesh do
on mousePoint click do (
case click of
1: nodeTM.translation = [0,0,0]
2: buildsomething ()
I'm not sure that you can, you have to store the verts, faces and other data and rebuild it on load and then store the trimesh in a local variable.
12-18-2008, 01:19 PM
Thanks for that, that makes alot of sense.
In terms fo storing meshes in the scripted object, am I forced to recalculate the object on, say, opening a maxfile? or can I store the vertex and face data in the parameter block?
What I'm thinking of doing is building a struct to contain the object data for use during the execution of the script(ie faceverts, vert_positions). I would then take the vertex positions and stick them in a #point3Tab. The problem is I don't know what "tab" I can put an array of faceverts in, ie #(#(a,b,c,d),#(e,f,g,h), etc). Maybe another point3tab. I guess I'd have to read the values back in 'as integer'.
Given the recalculation time involved in my script I would like to be able to store the mesh within the maxfile rather than recalculate it all the time.
The other route to take is storing the mesh as a hidden maxobject (or node, I forget!) and then rebuild the scripted-plugin using that mesh. This works, but is alot slower due to not keeping the data as a trimesh.
12-18-2008, 01:59 PM
Think I've made some progress... finally getting the hang of collecting variables :) ... and the mesh data is now getting stored in the two point3tab params.
Here's the code... is there any optimisations or better ways of doing this?
for f = 1 to obj.numfaces do (
verts = for s in (meshop.getVertsUsingFace obj f) collect s
this.cFacesTab[f] =[verts, verts, verts]
this.cVertsTab = for f = 1 to obj.numverts collect (meshop.getvert obj f)
What I'm suggesting works great as I have whole character rigs based on this now. What you store is a point3Tab for verts and faces verts, I also store smoothing group information so i can apply that as well. In the load handler for the plugin you can a function that builds and returns the mesh. This will only be called once on load. You can then also add parametric parameters to the mesh like a size or radius, store that as a float value and multiply the vert positions by that factor when you build the mesh.
12-18-2008, 02:30 PM
Good good...glad to hear I'm heading in the right direction!
Curiously, this only works for one mesh. What if I wanted to recreate n_meshes so I can apply transformations to the meshes individually when I rebuild them? Its a shame you can't create structs or nested arrays in the param block as it would be easy to this kind of thing.
12-18-2008, 02:30 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2015, Jelsoft Enterprises Ltd.