PDA

View Full Version : scripted plugins?


Awoogamuffin?
02-08-2006, 02:31 PM
Hi there...

ok, I've got a relatively complicated scripting project ahead of me. I work in architectural visualisation, and I just want to create a simple tool that will allow me to place trees in my scenery! Unfortunately, I've been trained in MEL but not Maxscript.

Anyway, I've written a few separate tools, such as one that will allow you to place the trees (simply textured planes), one that will keep a plane facing the active view etc. etc.

My problem now is making a single tool that will handle these trees and save them when I save the max scene. Ok, more concretely, here's what I want the tool to do:

- Allow the user to place a bunch of trees
- Allow the user to change the size of all trees, or just one tree
- All trees to be in one group
- All trees to face active viewport

Now I've been looking into scripted plugins, seeing as apparently I can save parameters in the max scene. What I would like is an array that stores all the trees, which is saved in the scene and can be accessed from various places. One example of why I'd like this array is to update all the trees whenever the active viewport redraws.

Unfortunately I can't seem to find a decent way of having a global array which will be saved and recovered as I close and open a file. Any ideas? Am I barking up the wrong tree as far as plugins are concerned?

Also, I would like scripts running for each individual tree. In Maya I had expressions that would control certain aspects of an object relative (for instance, objectA.rot.Y = objectB.rot.X/2). Is there anything like that in maxScript?

Or maybe someone can point me to a well commented scripted plugin I could rummage around in...?

marktsang
02-08-2006, 02:40 PM
look into persistent global variables for variables that save and load with the scene

to save the arrays i would use matrix3tabs in a parameter block

mark

Light
02-08-2006, 02:47 PM
Hi,

I would probably use a specific naming for the trees, instead of sticking global arrays in every max file.

So the trees would be like this: myNewTree001, myNewTree002, ... which then can be collected like so: $myNewTree*




Light

Aearon
02-08-2006, 10:06 PM
let me take a step back here: you probably don't need maxscript to have the trees facing the camera, you can use a lookat constraints for this. you will want to set these up using maxscript, but you don't need a script running on viewport redraw or anything

in max you can't directly disable seperate axis for the lookat constraint to have them only rotate on one axis like in maya's aim constraint (i assume you tried this as you're coming from maya), but you can get this behavior anyway. using the compiled lookat constraint will be much more interactive then maxscript... so i think you should definitely use it.

the setup is simple:
- create a point helper at the pivot of your planes, parent the planes to the helpers
- put a lookat constraint on the point helpers, add the cam as a target
- disable the inheritance flags for the two rotation axis you don't need.. this makes the plane only rotate on one axis

to answer your question about barking up trees: yes, i think you are barking up the wrong one, or at least up a tree that is more complicated than it needs to be from my point of view ;) i'd make this a simple macroscript, and i'd also use a naming scheme like light suggested so you can easily collect the trees after they've been created without worrying about data stored within the scene.

Kenzor
02-08-2006, 11:23 PM
Also, I would like scripts running for each individual tree. In Maya I had expressions that would control certain aspects of an object relative (for instance, objectA.rot.Y = objectB.rot.X/2). Is there anything like that in maxScript?

look at 'script controllers'. You can replace the default controller (like euler, tcb etc) with your own custom controller.



Unfortunately I can't seem to find a decent way of having a global array which will be saved and recovered as I close and open a file. Any ideas?

A simple method would be to use the 'user defined properties' of the object. Check the maxscript help under 'user-defined properties - node methods'

When you open you maxscript tool it could simple scan through all the objects in the scene looking for tree types.

something like

for obj in geometry where (getUserProp obj "BigTree") == true do append myBigarray obj

If you want to do more complex stuff then you need to check out 'custom attributes'

Am I barking up the wrong tree as far as plugins are concerned?

That depends on how many trees you placing and how much tweeking you want to do.
If you doing a one off simple scene then the method Aeron descibed would be fine.

If you need to do this a lot then I would consider a script. (Not least because custom attributes are very powerful and well worth learning if you're into that kind of thing.)

N.B

if you do try using custom attributes it's worth noting that

custAttributes.add $sphere01 CaTest

Means that all instances of $sphere01 will gain a shared custom attribute.But...

custAttributes.add $sphere CaTest BaseObject:false

Means that $sphere01 will gain a unique custom attribute, even if it has instances.
(this had me banging my head for days..)

CGTalk Moderation
02-08-2006, 11:23 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.